rotate other actors with main player

diamond000diamond000 Member Posts: 32
edited November -1 in Working with GS (Mac)
I have a top down view of my player . He rotates with self.rotate 90 degrees left and right when buttons are pressed. How do i get actors that he picks up to rotate with him 90 degrees. (like he picks up a gun have it rotate when he rotates)so it stays at the same spot on him. He can pick up more then one item at a time.

Comments

  • ApplaudAppsApplaudApps Member Posts: 308
    You'll have to use a game attribute like game.playerrotate instead of self.rotate and then constrain 1) game.playerrotate to self.rotate on the main actor and 2) constrain self.rotate to game.playerrotate on the picked up objects.
  • DrGlickertDrGlickert Member Posts: 1,135
    I'd use two constrain attribute on the "gun" actor and 1 REAL game.attribute

    Create a game.attribute that's a real attribute, call it game.PlayerRotation

    On your player do Constrain Attribute: game.PlayerRotation to self.rotation

    On the gun actor,
    Constrain Attribute self.rotation to game.PlayerRotation

    This will make the gun rotate with the player.
  • diamond000diamond000 Member Posts: 32
    i tried doing the constrain attribute and it will rotate with the player but my problem is it is offset from the player(it is 16 pixels up in the y) how do i keep it in the same angel when he turns( if i turn him 90 degrees counter clockwise then the gun should be 16 pixels offset in the x)this is what im trying to get to work.

    the gun needs to stay on his right arm.
  • diamond000diamond000 Member Posts: 32
    anyone know how to do it?
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Search for Example rotation in the new tab and download that. It shows hot to make something rotate from a point other than the center.

    The only difference is you will need to constrain your players rotation to a game attribute and then instead of a joystick controlling the rotation just constrain game.angle in the demo to the players rotation. and it will just always match it.
Sign In or Register to comment.