How do I rotate circle until it reaches position?

Get help using Construct 2

Post » Thu Oct 27, 2016 3:27 pm

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.
B
4
Posts: 12
Reputation: 224

Post » Fri Oct 28, 2016 10:42 am

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?
B
4
Posts: 12
Reputation: 224

Post » Fri Oct 28, 2016 4:48 pm

@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!
B
16
S
9
G
5
Posts: 74
Reputation: 4,120

Post » Fri Oct 28, 2016 9:58 pm

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

Also, a capx would be much appreciated!
B
4
Posts: 12
Reputation: 224

Post » Sun Oct 30, 2016 7:10 pm

@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!
B
16
S
9
G
5
Posts: 74
Reputation: 4,120


Return to How do I....?

Who is online

Users browsing this forum: Cub3D, David181, yiuyiu6666 and 19 guests