Hello, everybody!
I’m trying to make a game, and I need gameobjects with rigidbody to move circular around mouse position in some radius, when player clicks mouse button (like planet’s gravity simulation). I’ve found some decision, which use transform.position to do that (It’s not full):
if (Input.GetMouseButton (1)) {
timer += Time.deltaTime;
transform.position = new Vector3 (2*Mathf.Cos(Mathf.Deg2Rad*timer), 2*Mathf.Sin(Mathf.Deg2Rad*timer), 0);
}
But i need gameobjects to save them kinetic energy, that’s why i want to use rigidbody.
Also, gameobjects which have moved before player clicks button, should also save them kinetic energy, so I want to use AddForce method.
Can anyone help me in writing this code? Thank you!