Make the cam shake harder if the char is closer to a object

Get help using Construct 2

Post » Thu May 26, 2016 9:21 pm

If the object is not on screen, there is no shake. But if it is, start a cam shake that will growing as the char moves closer to this object.

I have this math that I'm using in the cam:

If 'Object' is on screen,
Set the Cam shake to: clamp(distance(Char.X,Char.Y,Object.X,Object.Y)/190,5,1)

It works, but is inverted. When the object is closer to the Char, the shaking magnitude is 1 instead of 5.
How can I invert this?
B
20
S
4
Posts: 385
Reputation: 2,270

Post » Thu May 26, 2016 9:26 pm

Set the Cam shake to: clamp(190/distance(Char.X,Char.Y,Object.X,Object.Y),5,1) shouId work I guess. You need to divide the shake factor at distance 1 (190) by the distance. When in doubt, check the math in excel.
B
15
S
6
Posts: 85
Reputation: 1,195

Post » Thu May 26, 2016 10:04 pm

Pulstar wrote:Set the Cam shake to: clamp(190/distance(Char.X,Char.Y,Object.X,Object.Y),5,1) shouId work I guess. You need to divide the shake factor at distance 1 (190) by the distance. When in doubt, check the math in excel.

Wow, that's it!
Thank you very much :D
B
20
S
4
Posts: 385
Reputation: 2,270


Return to How do I....?

Who is online

Users browsing this forum: Artcadev and 12 guests