- Home /
Move object to specific position with physics
Hi, I would like to make an dynamic jump pad function where i can input a specific position and have the function dynamically calculate the force and velocity i need to add depending on the declared position. I only need to do this on one axis, I want to drive over the jump pad and have the player to jump and land on the dynamically declared position on one axis - does any one know how to calculate this and add the right physics to make a nice smooth jump? any ideas, thoughts or a solution is very welcome.
/joe
Answer by DaveA · May 06, 2011 at 08:07 PM
You could read up on basic physics (google it) and see how to do projectile motion calculations. Note that there are many solutions to 'jump from here and land there' depending on the speed and angle of launch you want.
Pointers to specific articles that describe what you're talking about would be helpful.
I was gonna say http://lmgtfy.com/?q=projectile+motion+equation but this one looks promising http://electron9.phys.utk.edu/phys135d/modules/m3/Projectile%20motion.htm I think looking for 'range' is what you need.
Answer by Joshua · May 06, 2011 at 02:28 PM
It would depend on the velocity of the incoming object, it's drag, it's mass, it's physics material's bounciness + drag, the pad's physics material's drag and bounciness and of course the applied force and direction.
Unless there is something I'm forgetting I think it would be way easier to just Vector3.Lerp or Vector3.Slerp the transform of your object to a certain point.
Edit: a solution that would give you total control over the position but will still let it look 'real' (rather then my lerp solution, which would make it move in an unrealistic straight line), is using a spring joint. Have a look at DragRigidbody.js to have a working example. If you can't find this go to Assets > Import Package > Scripts > Select None > Select DragRigidbody.js
i think both answers are good and i will try using a joint today - the optimal solution would be Daves but if im able to use a joint this seems like a lot less work. i will post my solution later - thank you