Alright, I’ve typed this up three times now, only to lose my progress to the infernal web, so excuse me if this seems a little bit graceless about asking this question.
Basically, I’ve done some research around a particular error I’m having. Error:
BCE0024: The type ‘UnityEngine.Vector3’ does not have a visible constructor that matches the argument list ‘(UnityEngine.Vector3)’.
to be specific.
The error originates from the line…
myTransform.rigidbody.velocity = Vector3(lookDir.normalized * MoveSpeed * Time.deltaTime);
Now, I’ve done some research about this, myself. I’m told that I have to ‘construct’ things in order for Vector3 to be able to process them into an actual vector.
I’ve gone and done, testing it. I specified that the lookDir is the element which is causing the error. The rest functions well.
The problem though: lookDir is actually defined, so how is this error still occurring? Of course, to make any judgement on this, you’ll have to look at the script…
var Player : Transform;
var MoveSpeed = 4;
var MaxDist = 10;
var MinDist = 5;
var myTransform : Transform;
var distance = Vector3.Distance(Player.position, transform.position);
function Awake(){
myTransform = transform;
}
function Update ()
{
if (distance <2f)
{
var dist = Vector3.Distance(Player.position, myTransform.position);
var lookDir = Player.position - myTransform.position;
transform.LookAt(Player);
if(Vector3.Distance(transform.position,Player.position) >= MinDist){
myTransform.rigidbody.velocity = Vector3(lookDir.normalized * MoveSpeed * Time.deltaTime);
if(Vector3.Distance(transform.position,Player.position) <= MaxDist)
{
}
}
}
}
Why is the error occurring? Have I misunderstood what I have to do?