Roll-A-Ball Speed will not show under "PlayerController" script

My Roll-A-Ball Speed will not show up under my “PlayerController script” the way the tutorial did. I followed directions exactly the way the tutorial showed and it says next to " rb.AddForce (movement = speed);":
"cannot implicitly convert type ‘float’ to ‘UnityEngine.Vector3’

PLEASE HELP!!!

code i have currently below:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

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);
}
}

Change 2 lines to this:

Vector3 movement = new Vector3 (moveHorizontal * speed, 0.0f, moveVertical * speed);
rb.AddForce (movement);

Also, next time, please post in the scripting section and use the “Insert Code” button.

Thank you for your fast response!

After fixing the code my ball just rolls off the board, could you tell me what would fix this issue?

Well continue doing the tutorial, they’ll show you how :slight_smile:

https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial/setting-play-area?playlist=17141

1 Like

I have the same problem: when I tried to start moving the ball, it falls down along Y axis instead of going around on the ground. Someone told me that I should add rigidbody and collider to both them to add the physics. I don’t know how to do since I am new at the Unity. Could you explain what it means?

If you do the tutorial step-by-step, everything will work fine.

To add a component, click on an object, and in the Inspector, use the Add Component button to add a collider and/or rigidbody.

1 Like

can anyone send me the corect set of script

my script dosent work