Hey, I'm hoping you guys can help me. What I need to do goes beyond my math skills, and I'm not sure what to search for so here goes.
I'm playing around with physics in Construct. I've made a grenade that the player can toss. After some time it explodes. I want it to be so it pushes other objects and they fall (they have the physics behaviour as well).
What I want to do is push objects with force, towards a point that is determined by where the center of the explosion is:
1 is the center of the explosion, the circle being the area the explosion affects.
2 is the object that is being hit.
3 is the point I need to find, so I can make an event that says to push the object (2) towards point 3.
I'm guessing it has something to do with sinus or cosinus but I'm at a loss.
If Construct has ATan2 to solve for the angle of a line, then the following pseudocode should apply:
angle = ATan2(y2-y1,x2-x1) // equal to the angle of the line
deltaX = cos(angle) * distance // distance is the distance you want the object to move
deltaY = sin(angle) * distance
targetX = x2 + deltaX
targetY = y2 + deltaY
You use ATan2 to find the angle of that line, then use the cosine of that angle to get the change in X and the sine of the angle to get the change in Y.