Speed accumulation problem (python)

Hi! I was wondering why in this file:

http://www.pasteall.org/blend/35957

each time you add a duck (blue arrow), the speed of each duck increases.

Thanks for your answers!

(click on the green square to add a farm, then on the blue square to add ducks)

i dont know how to solve the problem but that effect seems cute ! http://s2.postimage.org/p2thvaw4/yoyo57.gif

:slight_smile: Thanks!

they are excited coz new members come. Thats why they run happily http://s2.postimage.org/p88na95w/yoyo143.gif! We can use it as a feature o.o its not a bug http://s2.postimage.org/p8aatlno/yoyo144.gif.

Idk why i comment like this , maybe coz you call those blue objects as ducks -.-


Nice duck :slight_smile:

each duck applies movements to all ducks on ducklist :smiley:

you need to a = have a duck controller run this each tick

or

have each duck only move itself

Every single duck calls the duckMove() function every frame. However, the duckMove function goes through the entire duck list and moves every single duck including itself. This means that if you have N ducks, each duck gets moved N times in a single logic tick instead of moving just once.

You should either remove the for loop from the function and have each duck just move itself or create a separate duck manager that moves all the ducks at once.

‘High 5 Mobious’

Your problem is that you’re running an instance of randpos.duckMove on each duck in the scene.

That means that the duck’s script should only be dealing with that particular duck’s behaviour. Instead, you have each duck applying behaviour to every duck. So for each duck that’s present in the screen, every duck gets the movement applied multiple times.

Rather than have the randpos.duckMove controller on the duck, place it on the camera. The camera will run the script once per frame, loop through each duck, give them their instructions, and that is that.

(Haha…took too much time trying to figure out how to word this. Sort of one of those things that much harder to explain than it really should be)

Ah yes, I see what’s the problem! Thanks BPR and Nines (sorry for forgetting you) and Mobious! (I forgot the script was attached to the duck (arrow))

http://www.pasteall.org/blend/35960

so many ducks in this thread @[email protected]

50 ducks and counting… -.-