How do I check if the x position of my object is 0?
As part of a small animation of the object, the y position is constantly changing and the x remains as zero. The purpose of the code is to set the IsTrigger from the BoxCollider2D from false to true when the object is in this animation. But the code bellow does not seem the be working.
if(transform.position == new Vector3(0,transform.position.y,0)){ GetComponent ().isTrigger = true; print ("on idle"); }
i think the issue here is the == its to accurate so the result is off by very little like 0.1 so the IF dosent work try > or < , i had a similar problem so i had to snap my object position when it got close to the target position to.
The ">=" "<=" "<" ">" can't be used when dealing with Vector3.. What do you mean by snapping?
check variables(x,y,z) with > or < not the whole vector 3 i am assu$$anonymous$$g you only need to check 1 variable X or y and by snapping i mean when the object gets close to your target position(within 0.5 / -0.5 for example) you force the object into the position(0,0,0) you want so that your if statement works.