In my game, I have 5 targets and a gunner. The gunner is supposed to
1) shoot 5 bullets to all of these targets.
2) wait a second after each shoot.
The target's angles are saved to an array called "targets"
This is how I do it
Local variable count = 0
For "attack" from 1 to 5
Spawn a bullet
Increase "count" by 1
System pick the "count"th bullet
Rotate to targets.At(count)
System pause 1 sec
Here are the problems
1) Only the 1st bullet flies to the target, the other bullets stay still right where they are spawned.
2) There is no pause between the spawning
Can you help me out?
Thank you very much
I think your problem might be that you are using 'rotate to' instead of 'set angle'.
sqiddster thank you for the response.
I changed it to 'set angle'. Now the 1st bullet can fly to a target, but the other won't. Moreover, they are still spawned at the same time
Correct me if I am wrong, but I have do things like this
For "a" from 1 to 6
Add 1 to "variable"
Text -> Append "variable"
Wait 2 secs
Expectation: Variable is increased, its value is printed, object is spawned
Reality: Text's content is 123456, after 2 seconds, objects are spawned.
I conclude that each statement in For loop is executed times before the next statement. It is strange compared to other language.
Can you explain it to me?
Develop games in your browser. Powerful, performant & highly capable.
I think your problem is using the wait action inside a loop. Try to redesign your code to avoid this, then see if it works.
After getting rid of all wait action, the result is still the same.
bullet.Set angle to(targets.At(count))
Thank you very much.