Translate(), Rotate() acceleration and deacceleration

My dear forum

Here comes my very first javaScript’ing question…

When I use myGameObject.transform.Rotate(myVector3) or .Translate(), I experience a short acceleration and deacceleration. Is is possible to control the inertia of this acceleration?

I guess what I’m really asking for is the easiest way to create a slow acceleration and deacceleration when I rotate an object.

That should be easy, eh?
Carl Email

First give your object the Constant Force component from the component menu, this will automatically add a rigidbody. Then you can give it a force which will smoothly accelerate the objects rotation or in a straight line. Then you can also change the drag value in the rigidbody component to affect the acceleration. For more control than that you would probably have to write a script.

http://unity3d.com/Documentation/Components/class-ConstantForce.html

Hi Carl. If you want to control the acceleration of the object’s rotation, you have two options. The easiest thing to do is put the object under physics control. To do this, highlight the object, and choose Component → Physics → Rigidbody from the top menu. Now you’ll see a rigidbody appear in the object’s inspector. There is a box checked next to the string “use gravity”. Uncheck this box. Now, in your script, change your code to:

myGameObject.rigidbody.AddTorque(myVector3);

This will gradually start spinning your object. If you attach this script to the Game Object that you want to spin, you can implicitly access the Game Object’s members. For example, just type:

rigidbody.AddTorque(myVector3);

EDIT: you can do the same thing for translation by using rigidbody.AddForce(myVector3)

Hope this helps!

Thanks Daniel and Ulognep

It simply works =)