c# - error CS1525: Unexpected symbol `transform' -
hi i'm making game in unity using c# , want implement teleport on key-press mechanic i'm having issues code
using system.collections; using system.collections.generic; using unityengine; public class teleport: monobehaviour { private transform player; void awake() { //find player object , set player = gameobject.findgameobjectwithtag("player").transform; } void update() { // checks if click space bar , gets -1, 0, 0 if (input.getkeydown(keycode.space) transform.position = new vector3 (-1, 0, 0); } }
i'd appreciate if tell me whats wrong or improve mechanic , make better in way.
you're lacking of )
here :
if (input.getkeydown(keycode.space) player.position = transform.position = new vector3 (-1, 0, 0);
which should :
if (input.getkeydown(keycode.space)) player.position = transform.position = new vector3 (-1, 0, 0);
Comments
Post a Comment