Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Simulate perfect circular motion with addforce

$
0
0
Hi, I,m trying to simulate circular motion in unity using different value of force. However, I can't actually perform a perfect circular motion using the AddForce() function. Like, when the velocity of an object is 10ms^-1 and radius from center is 10m, it should have a perfect circular motion with a centripetal force of 10ms^-2, but when it start moving it just lost control and never keep in a perfect circle track! This is my work: A rocket and a planet are initially placed in x=0, as shown: ![alt text][1] The rocket given an initial speed in y axis: void Start () { gameObject.GetComponent().velocity = new Vector2(0, speed); } The planet have a constant force pulling the rocket to it: //Fixed Timestep=0.02 void FixedUpdate () { // transform.position is position of a "planet" direction = (transform.position-rocket.transform.position).normalized; //rocket is a object circulating the planet with an initial velocity rocket.GetComponent().AddForce(direction*force) } I want to simulating the motion in different variable, so I don't want to hard code it by changing it's position. How can I do this with AddForce or other method? Thank You. [1]: /storage/temp/89948-temp.png

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>