- Home /
Error with vector3 initialization
Im getting this error :"Assets/_Scripts/PlayerController.cs(27,39): error CS1922: A field or property UnityEngine.Vector3' cannot be initialized with a collection object initializer because type
UnityEngine.Vector3' does not implement `System.Collections.IEnumerable' interface"
using UnityEngine;
using System.Collections;
//[System.Serializable]
//public class Bounday{
//
//
//}
public class PlayerController : MonoBehaviour {
public float speed;
// public Bounday boundry;
Vector3 Position;
public float xMin,xMax,Zmin,zMax;
void FixedUpdate(){
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis("Vertical");
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.velocity = movement*speed;
Position = rigidbody.position;
Position = new Vector3{
Mathf.Clamp (rigidbody.position.x,xMin,xMax),
0.0f,
Mathf.Clamp (rigidbody.position.z,Zmin,zMax)
};
}
}
Thanks
Comment
Best Answer
Answer by getyour411 · Feb 02, 2014 at 10:47 AM
Replace 27 Vector3 { with parenthesis and again on 31
Hey ! Thank you getyour411 for posting this anwser. I did not notice those were parenthesis in the tutorial video. I really need to pay more attention to the ponctuation....