Hello, I’m new to unity(5) The roll-a-ball tutorial (https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial) (step 2) requires code in C# fallowing the tutorial we obtain the fallowing code:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
private Rigidbody rb;
void Start ()
{
rb = GetComponent<Rigidbody>();
}
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement);
}
}
In the tutorial the sphere moves, when I hit the play button in editor I remain in same position (0,0.5,0) and I get the fallowing error: “The referenced script on this behavior is missing!” twice.
After some searching from this source(Move a ball using keybored - Questions & Answers - Unity Discussions) I’ve tried the fallowing:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public int speed = 5;
void FixedUpdate ()
{
float x = Input.GetAxis("Horizontal");
float z = Input.GetAxis("Vertical");
transform.Translate(x, 0.0f, z);
}
}
But got the same error “The referenced script on this behavior is missing!” twice
Is there something wrong with the code? Am I missing something?