How do I Make a sprites angle follow the mouse?

0 favourites
  • 4 posts
From the Asset Store
Total customisation of the input! You can combine inputs from all peripherals. Make your game accessible for everyone!
  • Hello, I would like to know how to make a sprite set it's angle to the mouse position without it using the origin point. I would like ti to use Image point 1 for example.

    Also, I need the player character, who is using an 8 directional movement behaviour, to move in the opposite direction of the mouse when clicked. Like it's being pushed.

    Thank you

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • use the function angle()

    so one way is:

    onMouseClick
    Set Sprite Angle to angle(sprite.x,sprite.y,mouse.x,mouse.y)
    
  • to give your player a "boost" give it bullet behavior (in addition to 8dir.

    Set Bullet Default Speed to 0 and Acceleration to -1600 and uncheck Set Angle

    Then:

    OnMouseClick
    Set Bullet Speed to 400
    Set Angle of motion to angle(sprite.x,sprite.y,mouse.x,mouse.y) - 180
    

    the negative acceleration will slow it down pretty fast. Not sure if this is the effect you were going for, but this is one way to do it.

  • If you are looking to set the rotation based on the angle between your sprite's imagepoint 1 and the mouse, use the solution that jobel gave but change the sprite.x,sprite.y to sprite.imagepointX(1), sprite.imagepointY(1)

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