How do I rotate circle until it reaches position?

0 favourites
  • 5 posts
From the Asset Store
You can change amount and speed of circles, length of lines and etc. Only 6 events.
  • So I couldn't explain very well in the title. I'm making a game where you're a circle and you click to walk somewhere. However, I want the circle to spin (roll) to that location. But I want it so that it calculates how far it is, etc, so the player/circle will be at angle 0 (up right) when it finishes rolling.

    What is the calculation to do this?

    (How the click to walk works for me)

    I have a 5x5 invisible sprite and when the mouse is clicked it travels to the mouse's x location and the circle/player's y. I then activate a custom movement to go towards that position. I then disable the custom movement when the player touches the sprite.

  • Also how would I tell which way the player is moving? Checking if the mouse's x is smaller or greater than the player's?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • iStudios

    Hi, I would love to help you with this, but first I have a quick question:

    When your circle spins, do you want it to spin in a realistic way like a wheel would or faster/slower like Sonic the Hedgehog would.

    If you want a real roll, and you want it to stop at angle 0 every time, that limits your distances to multiples of your circle's circumference (circle.width*pi). You can find the distance between two points by using the expression distance(x1,y1,x2,y2) and inputing your player's location and its target, dividing that by your player's circumference use floor(), round() or ceil() to find a rounded number of full rotation, and you find the exact distance you need to stop at for you character to stop at angle 0.

    Now, if you want to stop at the spot where you clicked, you will have to use the Sonic spin, or you can have your player keep rotating towards angle 0 after it has stopped. I'm sure there are lots of different ways to go about this.

    And yes, checking if Target.X > than Player.X will check the direction of your player.

    If you need it, I can make a capx to demonstrate one method or the other. Let me know!

  • I want it to be at 0 when it stops, not carry on. So the fast spin.

    Also, a capx would be much appreciated!

  • iStudios

    Ok, sorry for the wait... Here is a quick capx:

    https://www.dropbox.com/s/71xsa7gavnwlu ... .capx?dl=0

    I hope it helps. I'm sure you can mess with it and improve it!

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