Rotate sprite to direction?

This forum is currently in read-only mode.
From the Asset Store
Simple resize and rotate events for any sprite, quick and easy event sheet that you can use for your own projects.
  • Ok In a top down style I have a sprite, that uses the "Mouse" behavior, and in groups, attribute is set to "Center view on me", and mouse is set invisible.

    So basically Ive made a sprite into a cursor, so how to make the sprite rotate facing the direction its going?

  • In the 'Angle' category of the Sprite's actions, there's a few actions like 'Set angle towards position' and 'Rotate towards position'. For example, Set angle towards MouseX, MouseY will make the object look at the mouse.

  • I tried that, and either the sprite wont change directions, or it just works one time.

    I think the problem is that the sprite, basically is the cursor, so it cant look to it.

  • Here's a link to the cap:http://www.badongo.com/file/12108816

    Ive tried just about all I can think of.

    Thanks

  • In the 'Angle' category of the Sprite's actions, there's a few actions like 'Set angle towards position' and 'Rotate towards position'. For example, Set angle towards MouseX, MouseY will make the object look at the mouse.

    Ash, if he's got the Mouse behavior on the object, then it can't point towards MouseX, MouseY

    What you could try is this:

    Make two variables for your object called "lastX" and "lastY."

    +Always
      -Sprite: Set angle to (angle(lastX, lastY, MouseX, MouseY)
      -Sprite: Set sprite.value('lastX') to MouseX
      -Sprite: Set sprite.value('lastY') to MouseY
    [/code:19h3iw34]
    
    I think that should work.
  • No idea.

    It wont let me use lastX, as a value. I tried making it a private variable, and a global.

    So either Im doing it wrong, or Im an idiot... same thing.

    Wah, eeh Ill go make the honey pot.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I think he was typing pseudo-code. It should work if you use Sprite('lastX') instead of just lastX on its own.

  • Yes, that's what I meant. Sorry, I'm used to people understanding the whole pseudocode thing.

    The proper way to type it out in the editor would be:

    (angle(Sprite.Value('lastX'), Sprite.Value('lastY'), MouseX, MouseY)
    [/code:xtw1yy8h]
    
    But that's a lot to type, so I used pseudocode
  • Thats a bit better, still a little bit off.

    Thanks guys.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)