I have a game object ( satellite ) which is it is being attracted by another object(Sun). the satellite rotates (clockwise ) by holding mouse click, and on space key press(Jump), a force pushes the satellite against the gravity.
if satellite rotates around the sun whiling jumping, releasing the mouse button causes the satellite to rotate a bit back.
how to fix this?
is there any better way to achieve this gravitational rotation?
Tnx in advance.
void FixedUpdate()
{
if (Input.GetMouseButton(0))
{
transform.RotateAround(center.transform.position, Vector3.back, 50 * Time.deltaTime);
}
if (Input.GetKeyDown(KeyCode.Space))
{
direction= transform.position - center.transform.position;
GetComponent<Rigidbody2D>().AddForce(direction* 100 * Time.deltaTime);
}
axis = center.transform.position - transform.position;
GetComponent<Rigidbody2D>().AddForce(axis * 100 * Time.deltaTime, ForceMode2D.Force);
}
,