Help with Rotation to Constrained Actor Position?
Zenith_Gameworks
Member Posts: 310
Ok so I have a ninja character who has another actor, a bandana, that I constrained to follow the (x,y) position of the ninja character (I did this for collision purposes since my character is round and rotates himself). However, when the bandana follows the main actor as the main actor rotates, the bandana does not rotate. It just follows the ninja but at a 0 rotation the whole time. How do I get the bandana to rotate as the ninja rotates, while still being constrained to the (x,y) position of the ninja actor? Thanks ,
Zenith_Digital
Zenith_Digital
Comments
Back in a couple of minutes . . . . . . .
http://www.mediafire.com/?4l7e3mg9bznajue
. . .
Zenith_Digital
So at the moment you have this:
X position = (80*cos( game.A Rotation))+ game.A X
Y position = (80*sin( game.A Rotation))+ game.A Y
To move the bandana away (or closer) from the Ninja change these values:
X position = (80*cos( game.A Rotation))+ game.A X
Y position = (80*sin( game.A Rotation))+ game.A Y
Then to move the bandana around the Ninja (in an orbit) add an offset to the cos/sin angles here:
X position = (80*cos( game.A Rotation+120))+ game.A X
Y position = (80*sin( game.A Rotation+120))+ game.A Y
The only rule when changing these values is use the same value for XX*cos and XX*sin . . . . and the same deal with the offset, keep the two offsets the same . . . . otherwise you risk a journey to TrigonometryCrazyTown™
Example: http://www.mediafire.com/?f5aaklh666q8mq5
. . . . . . . . .
Using these two values you can position the bandana anywhere + and you can change its rotation by adding (or subtracting) whatever value you like from the rotation constrain behaviour.
. . . . . . . . . .
Just control the two values (the multiplier before cos and sin - and the angle offset) with an attribute - and change that attribute with an simple on screen slider.
If you stick a display text on the sliders you can use them to place the banana where you want then simply copy the values they show for your multiplier and your offset values.
Here's a very quick demo (I've also thrown rotation in):
http://www.mediafire.com/?nvcrhrvctcc4u1t
Just slide the three values around until you have the bandana where you want it, then use the three displayed values to replace the attributes of the same name in the bandana actor.
Hope that makes sense !
. . . . . .
Using just these two controls (the two on the far right) you can place the bandana anywhere on the screen.
One rotates the bandana around the Ninja, the other one pushes it further away (or nearer).
Think of a hand on a clock, if you can move the hand in a circle - and you can move a bead up and down the hand - you can then place the bead anywhere on the clock.
The multiplier pushes the bandana further away (or closer) to the Ninja.
The offset move the bandana in an orbit around the Ninja.
If increasing the multiplier moves the bandana horizontally, and you want to move vertically, then you need to add 90 to the offset.