Changing speed also changes direction.
MentalDonkeyGames
Member Posts: 1,276
Here´s the problem. I have an actor that spawns balls at random directions. The speed of the ball comes from an integer attribute i call BallSpeed. The value of this attribute increases when the player gets enough points in the game.
Everything works great, except for one weird thing.
If there is a ball still moving on the screen when the BallSpeed attribute changes, the ball also changes direction.
I made a sample project to better show you what i mean. Pressing the spacebar increases the BallSpeed attribute.
Download link: http://s000.tinyupload.com/index.php?file_id=94141916319367070787
Is it a bug on GS, or can someone tell me why is it behaving like that? …Or am i missing something?
Comments
@Nizoster
I'm not sure if that a Bug or by design,seems when you change speed it also generates a new random direction. I would file a bug report.
I made a change that will solve the issue in case you need help with that, File below.
And in the future you can just drag your zip file right into message body and it will appear like mine below will save trouble of uploading to offsite.
Strange !
The issue is that the random direction wants to reset itself every time the speed changes, I've noticed a few of these strange behaviours recently, this is similar a few others I've come across . . . and the same solution that deals with the others works here too.
In your ball actor make an integer attribute, let's call it 'DavidHasselhoff'
Add a change attribute behaviour that reads change DavidHasselhoff to random (0,360).
Now in your Move behaviour set the direction as self.DavidHasselhoff.
. . . . . . . . . .
This effects the speed of all the balls, that is to say that as the speed increases all the balls speed up . . . but if you want the faster speed to only effect 'newly spawned balls' (something very uncomfortable about that phrase) - then you can copy the game.speed attribute to a self.attribute and then use this self.attribute for the Move behaviour's speed, this way as game.speed increases balls that are already on the scene won't take on this new speed.
Hope that makes sense.
Oh, yeah> @BBEnk said:
Only if you are Pro
Same solution !
Thank you both. My next question would have been if there was a solution for this problem, but now i don't need to ask.
Mental Donkey Games
Website - Facebook - Twitter
I did not know that.