The error disapeared, but now I get 4 errors almost the same , to that line.
Operator ‘<’ cannot be used with a left hand side of type ‘float’ and a right hand side of type ‘Object’. Operator ‘<’ cannot be used with a left hand side of type ‘Object’ and a right hand side of type ‘float’. Operator ‘<’ cannot be used with a left hand side of type ‘float’ and a right hand side of type ‘Object’. Operator ‘<’ cannot be used with a left hand side of type ‘Object’ and a right hand side of type ‘float’.
And, after I put my script on my car, It didn’t show me to modify ‘minx’ / ‘maxx’ etc… This is my script now after some modification:
#pragma strict
public var position: Vector3;
function Start () {
}
function Update () {
var target;
var minx;
var maxx;
var minz;
var maxz;
var currx = transform.position.x;
var currz = transform.position.z;
if(minx < currx && currx < maxx && minz < currz && currz < maxz)
{
print("Successfull");
}
}
@Dantus
It works with float (doesn’t give any error), but still, I can’t change the minx/maxx/minz/maxz.
This is my script put on my car:
My script now:
#pragma strict
public var position: Vector3;
function Start () {
}
function Update () {
var target;
var minx : float;
var maxx : float;
var minz : float;
var maxz : float;
var currx = transform.position.x;
var currz = transform.position.z;
if(minx < currx && currx < maxx && minz < currz && currz < maxz)
{
print("Successfull");
}
}
Edit: I guess my Position is because of the useless public var I put in the top, I will delete it if this is the problem. But how can I define the others, also the target, if needed.
Unity’s inspector will never show you variables that are defined inside of a method. All of your variables right now are defined inside of your Update() method. You have to move them outside of that method before they will show up in the inspector.
Thank you very much guys. I finally made it with “public var minx/maxx/minz/maxz”, and it worked as I wanted.
Really nice help guys, I wish you the best!