How do I make a sprite move at a random angle?

Get help using Construct 2

Post » Sun May 22, 2016 4:48 pm

Hello there, Just wondering if someone could help? I have a game where you are a pair of footsteps and on the main menu I want those footsteps to move at random around the screen. I have a walk animation that I want to use.
B
15
S
5
G
2
Posts: 31
Reputation: 2,002

Post » Sun May 22, 2016 8:13 pm

Something like this?
https://onedrive.live.com/?authkey=%21A ... ion=locate

If you have any question, just ask it :)
B
20
S
4
Posts: 387
Reputation: 2,274

Post » Sun May 22, 2016 9:19 pm

Zathan wrote:Something like this?
https://onedrive.live.com/?authkey=%21A ... ion=locate

If you have any question, just ask it :)



Oh my God! Mate thank you so much I've been looking all day! I'm trying to get serious with construct since i graduated high school and I didn't even know how to do that :/
B
15
S
5
G
2
Posts: 31
Reputation: 2,002

Post » Sun May 22, 2016 9:19 pm

Zathan wrote:Something like this?
https://onedrive.live.com/?authkey=%21A ... ion=locate

If you have any question, just ask it :)



But could you maybe explain the process in a watered down version?
B
15
S
5
G
2
Posts: 31
Reputation: 2,002

Post » Sun May 22, 2016 10:01 pm

@AfterLifeGames
You are welcome!
An important note is that maybe there are best ways to achieve similar results. So, you can mess with the code and improve it!

What I did here is setting a random X and Y location every random amount of time. This location is stored in the two variables and is based on the window size, so the footsteps will never get lost beyond the screen.
The amount of time you can configure to fit better your project.

Another important thing is know exactly what you want when the random time is reached and a new location is setted.
In this case, I wanted that the footsteps turn slowly to the location.

So, in addition to being always moving forward, the footsteps will, with the lerp action, always turn to the specified X and Y in the screen.

Edit: Oh, I forgot.. the new location is setted when the timer reaches it's limit, but when the distance between the actual location and the footsteps is less than 30 too. This way, the footsteps will never be stopped.
B
20
S
4
Posts: 387
Reputation: 2,274

Post » Mon May 23, 2016 3:42 am

Zathan wrote:@AfterLifeGames
You are welcome!
An important note is that maybe there are best ways to achieve similar results. So, you can mess with the code and improve it!

What I did here is setting a random X and Y location every random amount of time. This location is stored in the two variables and is based on the window size, so the footsteps will never get lost beyond the screen.
The amount of time you can configure to fit better your project.

Another important thing is know exactly what you want when the random time is reached and a new location is setted.
In this case, I wanted that the footsteps turn slowly to the location.

So, in addition to being always moving forward, the footsteps will, with the lerp action, always turn to the specified X and Y in the screen.

Edit: Oh, I forgot.. the new location is setted when the timer reaches it's limit, but when the distance between the actual location and the footsteps is less than 30 too. This way, the footsteps will never be stopped.



Made sense! Thank you very much!
B
15
S
5
G
2
Posts: 31
Reputation: 2,002


Return to How do I....?

Who is online

Users browsing this forum: dop2000, Yahoo [Bot] and 6 guests