A couple of ways to move object in Unity3d

I found there are not only one way to move object in Unity3d, So I collect some methods as notes, and as a post sharing.

Use Force

space shooter

Like this small sphere, it use force to move to change direction.

float moveH=Input.GetAxis("Horizontal");
float moveV=Input.GetAxis("Vertical");
Vector3 movement=new Vector3(moveH,of,moveV);

reference doc roll a ball tutorial

Use RigidBody’s Velocity

It is like the below, but change the last one to:


Change RigidBody position directly


use Transform methods in Object’s transform



the speed is a float varity.

And the below codes are just code snippets, you can not use them directly.