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

0 favourites
• 3 posts
From the Asset Store
Ninja char for your game! Make your own Shinobi game with this art.
• 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?

• 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.

• ## Try Construct 3

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

Construct 3 users don't see these ads
• 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

• 3 posts