# Moving an object in 3D Space ~ Complexity

Hello referring to my old question which seems to be unanswerable as the character controller and rigidbody don’t work together.
here . So I have changed my approach a bit, Q - How about a rigidbody in 3D space that can will be accelerated with a button lets say A and the player could control its movement on axis with the arrow keys.

And is there a possibility that I could add an object called ‘head’ make it the main object’s child and move the head and the main object (sphere) will rotate and move towards it ?

Hello, well done for working on that question, it is by figuring out those 1st steps that you learn to understand unity very well, the worm game tutorial is quite good for learning character movement at some chapter in the tutorial. the worm game has a head, and some body segments that just follow weatherhead goes with smooth follow.

Here’s the 1st movement script I did for unity it’s for flying an aeroplane it’s got some basics in it. I think the commented out code afterwards is perhaps the one from the worm game, it also has a fire button and you need an invisible GameObject in front of the player from where the bullets are spawned, although you could also just make them spawn at GameObject + certain distance. There is constant force, relative force, etc. Have a look on youtube for marble games? And also the worm game.

Good luck

``````var speed = 15.0;
var rotspd = 10.0 ;
var bullitPrefab : Transform;

function Update ()
{

if ( Input.GetKey("mouse 1") )
{constantForce.relativeForce = 15000 * Vector3.forward
;}
else
{constantForce.relativeForce = Vector3.zero;}
if(Input.GetButton("forwards"))
{
transform.eulerAngles.x += rotspd * Time.deltaTime * 7;
}

if(Input.GetButton("backwards"))
{
transform.eulerAngles.x += -rotspd * Time.deltaTime * 7;
}

if(Input.GetButton("left"))
{
transform.eulerAngles.y += -rotspd * Time.deltaTime * 7;
}

if(Input.GetButton("right"))
{
transform.eulerAngles.y += rotspd * Time.deltaTime * 7;
}

if(Input.GetButton("Fire1"))
{
var bullit = Instantiate(bullitPrefab, transform.Find("spawnPoint").transform.position, Quaternion.identity);
}

}

/*var speed = 3.0;

var rotateSpeed = 32.0;

var bullitPrefab : Transform;

function Update ()
{
var controller : CharacterController=GetComponent(CharacterController);

//Rot
transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);

//fwd bck
var forward = transform.TransformDirection(Vector3(0,0,1));
var curSpeed = speed * Input.GetAxis ("Vertical");

controller.SimpleMove(forward * curSpeed);

if(Input.GetButtonDown("Fire1"))
{
var bullit = Instantiate(bullitPrefab, transform.Find("spawnPoint").transform.position, Quaternion.identity);