“MOVING THE PLAYER”, the script dont work, for more than i rewritte it it alwayhs said the same "The referent script on this behaviour is missing, can someone help about what happens ?
2 Answers
2Okay, first, copy and paste the code into a comment. Keep in mind, we don’t live in your computer. Second, try to take some time writing your question. If we spend time answering you, spend time correcting your grammar and spelling errors. I’ll try to get back to you when you send the script.
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
public float speed;
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 * speed);
}
Sorry WolfShadow, is my first here, im try to post better the next time, but thx a lot for your help
– alfredocaCool. Good work on the code. I believe @Lord_Ford is right here. Also, if your file name ( ie. PlayerControllerByMe) and public script class (ie. PlayerController) are different, as seen in the examples, this error can occur. They must be the same. Good luck!
– Wolfshadow
Do you have this script attached to the game object your are trying to move and does it have a Rigidbody component attached to it? @alfredoca
– Lord_Ford