- Home /
for loop error
for(float z =0F; z<worldZ; z + snap)
What's wrong with this? (worldZ and snap are floats)
Only assignment, call, increment, decrement, and new object expressions can be used as a statement.
Answer by Landern · Oct 22, 2014 at 12:37 PM
First of all, you're not doing anything.
z+snap does just the sum of the two parts, that's it, no evaluation, it's not pumping that value into a anything whatsoever, so that isn't helpful to progress the loop.
Assignment can be done as you saw in your error/exception message. But you can use a short hand to achieve what i think you're trying to do.
Either of these should work.
// long hand
for(float z =0F; z<worldZ; z = z + snap)
// short hand
for(float z =0F; z<worldZ; z += snap)
Also you don't need the F for a float if it's a whole number, only when using decimal. Its not enforced, your choice.
Your answer
Follow this Question
Related Questions
C# Changing Float with External Script 1 Answer
Distribute terrain in zones 3 Answers
Float not working all the time? 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Multiple Cars not working 1 Answer