How to increase a value relative to another value shrinking?

0 favourites
  • 4 posts
  • I'm making an effect that goes along the lines of "Player gets closer to object, intensity of effect increases."

    So far I've been using 'distance(Player.X, Player.Y, Object.X, Object.Y) to get the initial value, but when the player gets closer this value gets smaller. The effect works fine- just in backwards. The effect is stronger when the player gets further away from the object.

    Is there a simple command or thing I can do to "invert" this value in a way? For example let's just say that I want the intensity value to be '100' when the distance between the player and object is 0 pixels (touching).

  • ..you need to subtract distance fom X value....100-(distance/2)

    capx:

    http://s000.tinyupload.com/index.php?fi ... 3994135969

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks!

    To be honest I'm confused as to why this works but I'm glad that it does. I actually did try subtracting the distance from a constant 100 but it acted all wonky.

    The key is the /4 after the distance. I don't understand why it's there but I understand that that's the reason why my attempt didn't work.

  • General J

    if you use ...100-distance ...this will work... when distance is less than 100

    ....................100-distance/2...this will work... when distance is less than 200

    ...................100-distance/3..this will work.... when distance is less than 300

    ........etc

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)