Roll A Ball Tutorial Movement Issue

Hi, I ham following the roll-a-ball tutorial and the issue I am having is that when I try to move the ball the ball lists off of the plane/ground about 1 inch before moving in the direction I want it to go in.

If I move the ball to the left, it lifts about an inch and then moves over to the left. Same when moving right.

Any ideas how I can fix this/what the problem is?

I copied the script directly from the tutorial and so would have thought the script was ok.
Many thanks

For information the script is;

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour
{

public float speed;

private Rigidbody rb;

void Start()
{
rb = GetComponent();
}

void FixedUpdate()
{
float moveHorizontal = Input.GetAxis(“Horizontal”);
float moveVertical = Input.GetAxis(“Vertical”);

Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

rb.AddForce(movement * speed);
}
}

Does the ball stay an inch apart from the ground or does it come back to the ground when not moving?
Check your colliders. Your collider must be bigger than your mesh.

I will check thanks. The ball stays in the air even when it moves.

I left this project alone for a while so I could learn a little more but still cant find a solution for the floating ball.

The ball Y position is set to 0.5 as the instruction video.
But when I press play it rises to Y position 1.

The two images below show before and after the play button is turned on.

Then when I press play:

You can clearly see that the ball has risen and the Y position shows 1. So this doesnt seem to be the plane moving downwards. It stays at zero.

Any advice appreciated. Thanks.

That’s strange. Are you sure the plane object below you (and its collider) are properly setup? It could be they are higher, and that pushes the ball up. That’s all I can think of …

Have you tried recreating the project?

I did mess it up in the beginning and so restarted it and this happened.

I will try again though now you bring it up.

I did follow the tutorial as exact as possible. I will redo it though now I can concentrate on this project. Thanks for the response. I do believe that the plane is setup at zero and the colliders seem to match up ok.

Ah, I solved it.

All of my focus was on the player/ball. I unticked “Convex” in the plane collider and no the ball sits on the plane. I believed it was ticked by default so left it alone when I looked previously.

Thanks for the push guys. Much appreciated.

No problem. That’s what I was wondering about :slight_smile:
Glad you got it resolved. Have fun with Unity & games :wink:

1 Like

Thanks methos5k. Have a good one.

No prob. Thanks - you, too :slight_smile: