Hi,
I need to have all objects within a radius of a particular object need to get attracted to it..and move towards it.. like a big magnet.
Is there a inbuilt way to do that.
Try this:
http://www.scirra.com/forum/how-do-i-implement-magnet-behaviors_topic55225_post344797.html#344797
Develop games in your browser. Powerful, performant & highly capable.
Nice. :D
R0J0hound .. could you point me to a reference for those forumlaes.. how did you arrive at it?
The force calculation is a simplification of gravitation.
http://en.wikipedia.org/wiki/Newton%27s_law_of_universal_gravitation
So that gives the force, and the angle should be toward the magnet so I converted from polar (distance, angle) to caresian (x,y) so I could sum up the forces before applying them to the player.
http://en.wikipedia.org/wiki/Polar_coordinate_system#Converting_between_polar_and_Cartesian_coordinates