# Hi. sorry, pls help me... how do i make the ball move in all four different direction?

so far it is only one direction. sorry… btw this is my code

`````` void Update()
{
if (!started)
{
if (Input.GetMouseButtonDown (0))
{
rb.velocity = new Vector3(speed, 0, 0);
started = true;

}
}

Debug.DrawRay(transform.position, Vector3.down, Color.blue);

if (!Physics.Raycast(transform.position, Vector3.down, 1f))
{
gameover = true;
rb.velocity = new Vector3(0,25f, 0);

Camera.main.GetComponent<camera>().gameOver = true;
}

if(Input.GetMouseButtonDown(0) && !gameover)
{
switchdirection();
}
}

void switchdirection()
{
if(rb.velocity.z > 0)
{
rb.velocity = new Vector3 (speed, 0,0);
}
else if (rb.velocity.x > 0)
{
rb.velocity = new Vector3(0,0,speed);
}
}
``````
• if (Input.GetMouseButtonDown (0))

You’ll want to change this so it can handle different types of input (so you can enter eg. WASD), so Input.GetKey(KeyCode.W)

• rb.velocity = new Vector3(speed, 0, 0);

You will want to set different velocities for you object. a negative speed for opposite effects and putting speed in a different direction as well eg.

rb.velocity = new Vector3(0, 0, -speed);

then just copy/paste for any other sections if you need to (or put it in its own function)

You can get the inputs for all horizontal / vertical defined keys with

``````float horizontal = Input.GetAxisRaw("Horizontal"); // same with "Vertical"
``````

You can then use this input to calculate a velocity, or for the sake of argument just use it as velocity:

``````rb.velocity = new Vector3(horizontal, rb.velocity.y, vertical);
``````

That said, if you are using Rigidbody to make use of physics, it is not recommended to directly set the rb.velocity. Instead you want to apply a force to the rigidbody. Controlling things with physics is a bit harder, so unless you need physics, i would remove the rigidbody and directly control the transform.position. There are tons of tutorials on this kind of basic character controller stuff.