Translations

Know another language? Translate this tutorial!

Using a pivot point for rotating objects

Favourite 19 favourites
Tutorial written by programathsOriginally published on 22nd, July 2011 - 6 revisions

When an object is on a pivot and you wish to rotate it, it becomes a little harder because you can't simply rotate from it's centre. You need to rotate from it's pivot point.

Take the following situation:

Situation

Rotation depicted


Explanations

1) Before rotating the object, calculate the joint position.
2) Rotate the object.
3) Calculate the new position of the joint.
4) Compute the delta and add it to the object position.

Code

Some code


Enjoy !

Unlock your full gamedev potential

Upgrade to the Personal Edition of Construct 2, it has way more features and won't holding back from making money and using your full creativity like the free edition does. It's a one off payment and all Construct 2 editor updates are free for life!

View deals

Plus, it's got a lot of additional features that will help you save time and make more impressive games!

Congratulations on finishing this tutorial!

Did you learn a lot from it? Share it now with your friends!

Comments

3
ludodesign 30.9k rep

Funny... cool. Good work.

Wednesday, July 27, 2011 at 9:05:13 PM
1
blackvikinggames 4,934 rep

I needed this for a golf game.

Saturday, March 24, 2012 at 6:53:16 PM
0
BrunoCasali 2,304 rep

Hey, to work out this example you used an image of that size?

Sunday, April 14, 2013 at 2:33:31 AM
2
GameNado 987 rep

Hey. I notice this tutorial is a bit old so I don't know if this feature was available back then, but you can change the point of origin for the sprite now. Hence you can rotate from a pivot without any additional events : ).

Sunday, August 04, 2013 at 9:40:48 AM
0
Digilogue Games 1,404 rep

I may be being silly, but how would I change the pivot point?

Tuesday, December 10, 2013 at 6:55:20 PM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.