Random Object Movement Question
CharlieG97
Member Posts: 52
Hey guys. After a certain time period in my game I want to spawn an actor that initially starts moving in a random direction then bounces off any of the 4 walls surrounding the rectangle arena if it hits them. I then want it to bounce off the walls (already done this). I finally want it to increase its speed over time so it bounces around faster and faster. Any ideas?
Comments
Are you asking for help with the increasing speed?
Make 2 game attributes. "speed" and "speed modifier" or any other names you want, of course. Set the initial values to something that makes sense, but I strongly recommend setting speed modifier to 1 right now.
Inside each actor, you want a behavior that will constantly be checking itself so place it in a timer with a very low number. Set the velocity of the actor equal to speed * speed multiplier.
In an outside actor, you can increase the speed multiplier with a timer. Set up a timer behavior and every few seconds you can set speed modifier equal to speed modifier * 1.1
This will give you a steady increase in speed. If at any time you want to change the base speed of the actors, just change the attribute "speed" that you created earlier.