Help with Rotation to Constrained Actor Position?

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

Comments

  • Zenith_GameworksZenith_Gameworks Member Posts: 310
    Bump...
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    Bump...
    Let me make you a very quick demo . . .

    Back in a couple of minutes . . . . . . .
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
  • Zenith_GameworksZenith_Gameworks Member Posts: 310
    Thank you, you're an invaluable help as always ;),

    Zenith_Digital
  • Zenith_GameworksZenith_Gameworks Member Posts: 310
    Hey, I got everything to work except for one thing. The bandana always stays toward the bottom of the ninja, not next to the head where it is supposed to be. Any advice on how to shift its position?
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    Hey, I got everything to work except for one thing. The bandana always stays toward the bottom of the ninja, not next to the head where it is supposed to be. Any advice on how to shift its position?
    Yeah, it gets a little confusing, but you need to change the multiplier in front of sin and cos (on the bandana actor) - and then stick in an offset after the sin and cos angle (also on the bandana actor).

    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.

    . . . . . . . . . .
  • Zenith_GameworksZenith_Gameworks Member Posts: 310
    edited March 2013
    Ok this is really weird the x position is working but the y position isn't changing...
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    Ok I will try it soon.
    If you can't get your head around the maths or are just lazy like me take the easy route.

    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 !
    . . . . . .
  • Zenith_GameworksZenith_Gameworks Member Posts: 310
    The x works but the y isn't changing at all?!
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    The x works but the y isn't changing at all?!
    I'm not sure what you mean, there are no controls for X or Y, the controls are for the sin and cos multiplier and the angle offset.

    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.

  • Zenith_GameworksZenith_Gameworks Member Posts: 310
    Whenever I tinker with the equations, the horizontal position of the bandana changes but the vertical position, the one I want to change, does not move when I edit the multiplier.
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    Whenever I tinker with the equations, the horizontal position of the bandana changes but the vertical position, the one I want to change, does not move when I edit the multiplier.
    Take a quick look at the demo I made for you in the above post, the one with the controls, it will help you understand what the constrains are actually doing.

    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.

  • Zenith_GameworksZenith_Gameworks Member Posts: 310
    Sorry, it's still not working. Do you think you could fix it in my project?
  • SocksSocks London, UK.Member Posts: 12,822
    Sorry, it's still not working. Do you think you could fix it in my project?
    I'll have a go, PM me the project - or just the part you need looking at.
  • Zenith_GameworksZenith_Gameworks Member Posts: 310
    edited March 2013
    Ok I sent it.
  • Zenith_GameworksZenith_Gameworks Member Posts: 310
    How did you combine the two images into one?
  • SocksSocks London, UK.Member Posts: 12,822
    How did you combine the two images into one?
    Photoshop, cut, paste, move, save.
  • Zenith_GameworksZenith_Gameworks Member Posts: 310
    I figured, but you got the two images into one with a very specific border size so that the bandana sticks out and if you constrain the ninja to a collider it works out. Honestly, I'd rather do the trig stuff. It worked for me easier than hoping the images and the collisions will work out exactly as I want them to.
  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2013
    Honestly, I'd rather do the trig stuff. It worked for me easier than hoping the images and the collisions will work out exactly as I want them to.
    Yeah, use whatever works best for you !

    :)
Sign In or Register to comment.