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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -