How would I create an if stament that would do something like this:
if(position in world = 3)
{
dosomething();
}
How would I create an if stament that would do something like this:
if(position in world = 3)
{
dosomething();
}
A position would typically be a 2-d or 3-d coordinate, not a scalar, so ‘position == 3’ doesn’t make much sense.
Can you clarify what you mean exactly?
oh ya kinda forgot about 3d. A better example would be:
if(object position in world = (3,0,0))
{
dosomethine();
}
Comparing coordinates exactly will rarely be effective due to floating-point imprecision. Here are two alternatives though:
Compute the distance between the entity position and the target position. If the distance is below some threshold, consider the entity to have reached the position.
Place a trigger of the desired dimensions at the target position and take the appropriate action in the ‘on trigger enter’ callback.