View Full Version : Variables acting up
rookie101 01-29-2011, 04:34 AM http://www.youtube.com/watch?v=MNWWdaq0cW8
After executing the script I replace one value(the y value within the move command ) with a variable that has the same exact number that was there before ".1" I execute it again and I get a different result. I recorded it video qualtiy not that clear :/.
|
|
NaughtyNathan
01-29-2011, 08:54 AM
look at the output when you submit: $moveY = .1;
// Result: 0
so therefore $moveY must be an integer. This is why it's not a good idea to initialise or declare your variables without a type (until you know exactly what you're doing)
float $moveY = .1; // the "right" way to do itWhenever you input/submit anything into the script editor unscoped you define it as global. so you defined $moveY as a global int, then referenced it inside a (global!) proc.
and that's why you get a different result.
:nathaN
haggi
01-29-2011, 01:21 PM
With one exception:
float $floatArray[] = {1, 2.2, 3.3};
Gives you an integer array instead of an float array because the very first number of the values is an integer.
rookie101
01-29-2011, 03:59 PM
Ahh ok thx much appreciated
CGTalk Moderation
01-29-2011, 03:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.