I keep getting this error when I run the non-working code. Could anyone help me with this?
Assets/NewBehaviourScript.cs(17,27): error CS1061: Type UnityEngine.Component' does not contain a definition for
AddForce’ and no extension method AddForce' of type
UnityEngine.Component’ could be found (are you missing a using directive or an assembly reference?)
//Non-working code.
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public float moveSpeed;
private Vector3 input;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
input = new Vector3(Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
rigidbody.AddForce(Input);
print (input);
}
}
//Working code.
UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public float moveSpeed;
private Vector3 input;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
input = new Vector3(Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
print (input);
}
}