Question by
zanderness · Oct 02, 2015 at 01:10 AM ·
c#tutorial
roll a ball Assets/Scripts/PlayerController.cs(17,75): error CS1729: The type `UnityEngine.Vector3' does not contain a constructor that takes `4' arguments
i keep getting this error even though i copied the script exactly from the tutorial
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
private Rigidbody rb;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3(moveHorizontal, 0,0f, moveVertical);
rb.AddForce(movement);
}
}
Comment
Best Answer
Answer by Suddoha · Oct 02, 2015 at 01:49 AM
There's one argument too much in the constructor of the Vector that you're trying to create:
Vector3 movement = new Vector3(moveHorizontal, 0,0f, moveVertical);
If you need to write a float value, you need to use a dot ( 0.0f ):
Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
But in this case, simply 0f (or 0) will just do as fine as 0.0f
Vector3 movement = new Vector3(moveHorizontal, 0f, moveVertical);
now it says The referenced script on this Behaviour is missing!