- Home /
Need help with physics
Basically i want the player/rocket to follow a point on the screen where user touches. But It's based on physics. Force must be added when user touches somewhere and the rocket has to reach that point. Gravity is there too. If the rocket passes the point then it has to come by using forces. This is the game http://www.flashyland.com/219-jeux-flash-vol-Space-Oil.html (click the red button on the bottom left side and then green button. Arrow keys to play).
The rocket rotates too. I'm not good in physics at all.
Well, before being good or not with physics, you should post your script or what you tried to do :)
Don't just ask for a script. $$anonymous$$aybe I'll give you one if you can explain and convince me why I should be helping you ins$$anonymous$$d of doing my own projects. Explain why I should write a script specifically for you when it doesn't help me at all.
Answer by Fornoreason1000 · Jul 24, 2015 at 12:58 PM
First try to breakdown your goal into much much smaller goals. I Won't give you a script (it won't benefit you anyway), but I'll Address the steps of making one. There will be more consideration as you start coding but this will get you started on what you need to do.
First We have our input issue, we need to get our input into something usable. Touch.position is in Pixel Coordinates and our "rocket" is in World Coordinates, so we need to Convert that using Camera.ScreenToWorldPoint method.
Next is our desired Direction, this will be the Difference of the Rockets Position and the Touch position Vectors.
Next is out Angular Velocity Problem, you want it to rotates to your desired direction, or it will thrust in the wrong direction. this can be solved by adding a torque to your particular axis until its forward direction lines up with the desired direction, to stop further rotation, set the angularity to zero .
Lastly is Our Added Force Distance problem , basically we only want thrust to be applied so log there is distance between the rocket and its destination, a simple distance calculation can solve this one
Hope it helps
Your answer
Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
Car goes a bit left when moving 1 Answer
Compound Collider Moving Parts? 4 Answers
Top-Down Camera Trouble 1 Answer