c# - checking the states in unity -
i wanted animate object in unity. first, want check player states. have use enum naming states. here code checking state:
switch(playerstatecontroller.playerstates) { case playerstatecontroller.playerstates.idle: break; case playerstatecontroller.playerstates.left: transform.translate(new vector3(-1.5f * time.deltatime, 0.0f, 0.0f)); break; case playerstatecontroller.playerstates.right: transform.translate(new vector3(1.5f * time.deltatime, 0.0f, 0.0f)); break; }
but have error:
expression denotes 'type', 'variable', 'value' or 'method group' expected
public class anyclass { public enum playerstate { idle, left, right } }
-
public class anyotherclass { void dostuff(playerstate state) { switch (state) { case playerstate.idle: break; case playerstate.left: transform.translate(new vector3(-1.5f * time.deltatime, 0.0f, 0.0f)); break; case playerstate.right: transform.translate(new vector3(1.5f * time.deltatime, .0f, 0.0f)); break; } }
Comments
Post a Comment