unityscript - C# not running in Unity? (Basic) -
so, i'm playing around c# code in unity first time. i'm creating little script dink around with, not actual use. error get. (only assignment, call, increment, decrement, , new object expressions can used statement)
using unityengine; using system.collections; public class movement : monobehaviour { public int speed = 10; public int money = 10; // use initialization void start () { } // update called once per frame void update () { if(input.getkey(keycode.w)) { transform.translate (vector3.forward * speed * time.deltatime); } if(input.getkey(keycode.a)) { transform.translate (vector3.left * speed * time.deltatime); } if(input.getkey(keycode.s)) { transform.translate (vector3.back * speed * time.deltatime); } if(input.getkey(keycode.d)) { transform.translate (vector3.right * speed * time.deltatime); } if(input.getkey(keycode.return && money >= 10)) { debug.log("you bought sword!"); money - 10; } else { debug.log("you don't have enough money!"); } } }
the error in title. won't let me run it. know did wrong? : )
it looks want
money -= 10;
not
money - 10;
the first decrement allowed second expression (represents value).
Comments
Post a Comment