Can't call object by name in script?
by Tony Dormanesh · in Torque X 2D · 11/30/2011 (10:03 am) · 1 replies
This seems super simple, but I'm having trouble.
I just want to do something simple to start, like rotation an object through script.. It's very easy to do in the editor, but trying to do it through script I get errors.
First, I created the object in the editor, plopped it in the game space then gave it a name, "guy".
I created a separate script file for guy and executed it in the main game script file.
I did an echo in the guy.cs file to make sure it was working and it was.
Then did something simple like:
guy.setRotation(90);
and I get this:
game/gameScripts/guy.cs (0): Unable to find object: 'guy' attempting to call function 'setRotation'
Seems easy enough, I'm probably just missing some simple yet important step.
I just want to do something simple to start, like rotation an object through script.. It's very easy to do in the editor, but trying to do it through script I get errors.
First, I created the object in the editor, plopped it in the game space then gave it a name, "guy".
I created a separate script file for guy and executed it in the main game script file.
I did an echo in the guy.cs file to make sure it was working and it was.
Then did something simple like:
guy.setRotation(90);
and I get this:
game/gameScripts/guy.cs (0): Unable to find object: 'guy' attempting to call function 'setRotation'
Seems easy enough, I'm probably just missing some simple yet important step.
About the author
Always working for "The Man" and always seem to be part of downsizing. Looking to do stuff on my own now.
Torque Owner Joao Cardoso
Default Studio Name