Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | krokoloko |
I’m writing a PlayerMovement script and want to set the move direction variable to a zero vector and saw in the documentation that the Vector2 class contains constants that would allow me to simply use that instead of setting the move direction to a new Vector2(0, 0).
This is the code that where I want to se the move direction to a zero vector.
public void Update(float delta)
{
switch(state)
{
case MOVEMENT_STATE.NONE:
break;
case MOVEMENT_STATE.MOVING:
accumalative = MIN(accumalative+delta, acceleration_time);
break;
case MOVEMENT_STATE.MOVE_STOP:
accumalative = MAX(accumalative-delta, 0);
if(accumalative <= 0)
{
move_direction = Vector2.ZERO;
state = MOVEMENT_STATE.NONE;
}
break;
default:
break;
}
}
And this is the error the compiler gives me.
PlayerMovement.cs(82,31): ‘Vector2’ does not contain a definition for ‘ZERO’.
Would appreciate it if someone could show me how it’s done (I’m pretty rusty with c# scripting after I made my switch to c++).