Psychics handled transform.RotateAround

Hello!As the tittle sais : Can i somehow get the effect of RotateAround but if i stop running that function the object will fly with the force it gained?
Let’s say i have an object orbiting another and it gets out of the orbit.

var Planet : Transform;

function Update(){

if(Input.GetKey("w")){

transform.RotateAround(Planet.position, Vector3.up, 50 * Time.deltaTime); //and if i release W key it doesen't stop suddenly.It carries on flying on a dirrection with the force it gained while orbiting

}
}

I’m sorry for my english,i hope you understood me.Please help :frowning:

The things you are asking for are in the Rigidbody section. There is no specific Rotate at position so you would have to mathematically figure it out.

So lets do a little experiment… lets observe…

Vector3.Cross(Vector3.up, Vector3.forward) == (1.0, 0.0, 0.0)

This means, that if the up vector of the planet is vertical to the world, a object in the forward position(0,0,1) would move right(1,0,0) by using the cross vector.

Vector3.Cross(Vector3.up, Vector3.right) == (0.0, 0.0, -1.0)

This means that when the object is now 90 degrees on the right side, the movement would then turn to backward position.

This means that if we used Vector3.Cross(transform.up, transform.InverseTransformPoint(object.position).normalized) we would get the cross vector used to make it rotate clockwise around the planet. The only question then is this a real or relative direction. You test to see if it is either. If things dont move the way you want, try transform.TransformDirection(moveVector);

Now, for your question. Yes, it is totally possible to rotate something around, and then stop the rotation and have it continue in the direction. (remember to turn gravity off. ;))

Thanks!It helped me alot!
http://www.unifycommunity.com/wiki/index.php?title=Simple_planetary_orbits
Here i found some allready made orbiting scripts :smile: