Help with rotating gun on a naval ship

mrglocklingmrglockling Member Posts: 258
edited January 2012 in Working with GS (Mac)
What is the best way for me to make several rotating cannons on a navy ship that rotate to the mouse position and stay mounted on the ship? (The ship will move in any direction)

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    make 2 real attributes and constrain those attributes to the ships x and y.

    Then constrain the cannon's position to those attributes. You can add any offset you would like for them in the expression editor.


    Then to get them to rotate to face the mouse, you can constrain the rotation to vectorToAngle(mouse.position.x-self.position.x,mouse.position.y-self.position.y)

    cheers
  • scrapee_netscrapee_net Member Posts: 424
    ^ or jud add a rotate to position behavior, and put mouse x and y.
  • mrglocklingmrglockling Member Posts: 258
    Thank you
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited January 2012
    I have two videos on turrets as I'm building a tank game you might find helpful. The first is tracking an enemy with a rotating turret and the second is turret artificial intelligence.









    Gleeson Group Media
    UNoffical Gamesalad Guide
    FREE and easy to use. Contains all well done video tutorials for Gamesalad.
Sign In or Register to comment.