How to increase a value relative to another value shrinking?

Just started using Construct 2? Post your questions here

Post » Fri Apr 17, 2015 6:02 am

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).
B
21
S
5
Posts: 109
Reputation: 1,500

Post » Fri Apr 17, 2015 7:13 am

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

capx:
http://s000.tinyupload.com/index.php?fi ... 3994135969
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072

Post » Fri Apr 17, 2015 7:39 am

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.
B
21
S
5
Posts: 109
Reputation: 1,500

Post » Fri Apr 17, 2015 8:05 am

@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
B
67
S
24
G
7
Posts: 1,518
Reputation: 11,072


Return to Beginner's Questions

Who is online

Users browsing this forum: Studio Mercato and 1 guest