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

0 favourites
  • 6 posts
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • 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.

  • Something like this?

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

    If you have any question, just ask it <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Something like this?

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

    If you have any question, just ask it <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    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 :/

  • Something like this?

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

    If you have any question, just ask it <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    But could you maybe explain the process in a watered down version?

  • 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.

  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)