Can't understand why formation moving code doesn't work

Hi everyone.

I had a go at moving the formation myself before watching the lecture. I came up with the following solution:-

http://pastebin.com/JDthNivp

This, to me, should work, but I can’t understand why it doesn’t.
Any ideas?

Thanks in advance.

So… the first thing I notice and am going to point out, is that using the “Padding” Variables in your start function means that the “edge” of your play space is calculated only once. which I think means that changing your padding variable in the editor won’t cause a change in the behavior of your formation. the rest of that is okay, but I would recommend including the padding in your calculations at lines 34 and 39 such that the edge number is set then, rather then at startup.

Line 30 and 31 seem to be attempting to do the same work as the “modify” on line 37 or 42. and that’s going to cause a weird behavior.

try commenting out line 30 and 31 and change “EnemyMove” on lines 37 and 42 to “EnemySpeed” and tell me if that’s closer to the intended behavior.

if this works, then your issue was the difference between the “modify” and the “Set” and you basically did the same work twice…if that helps… I’m trying to describe the issue and I don’t think I’m doing a good job… so ask questions if you need to.

Privacy & Terms