How to make an actor rotate to follow mouse

In my game I'm making I need to have a rectangle rotate to follow the direction of the mouse. This would drastically improve the gameplay, and it would be nice to get an answer ASAP. Thanks.

Comments

  • SLOCM3ZSLOCM3Z Member Posts: 797

    @TimeBombGames‌ Here is a pic of how to do it :smile: (Change the rotate speed to what you want it to be)

  • SLOCM3ZSLOCM3Z Member Posts: 797

    Oh, sorry. In the first box is game.mouse.PositionX, and the second is game.mouse.PositionY, then in the third box it is the x again just raw

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @TimeBombGames and welcome to the Forums (and possibly GSC).

    Here's a rather fine template made by @Tatiang in which you can use to apply to what you're after.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Everyone wants an answer ASAP so no need to mention that. I've never heard someone say "This is what I need help with but I'd like to wait a while before I get an answer."

    More to the point, Constrain Attribute self.Rotation to vectorToAngle(game.Mouse.Position.X-self.Position.X, game.Mouse.Position.Y-self.Position.Y)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Twisted WireTwisted Wire Member, PRO Posts: 13

    Thanks everyone, you've been a big help :smile:

  • SLOCM3ZSLOCM3Z Member Posts: 797

    Playing with this attribute is fun :lol:

Sign In or Register to comment.