How do I rotate object from a defined position toward Mouse?

0 favourites
  • 5 posts
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.
  • Hi everyone,

    I try to create several objects from Touch Start Position that rotate toward Mouse Position.

    They also move toward Mouse Position.

    The issue is that I would like to change the pivot point of the created objects so they rotate from the Start Position. So, all my objects rotate and stay aligned.

    I tried several approaches such as Set angle(StartX,StartY,Mouse.X, Mouse.Y), tried Pin behaviour by creating a sprite from Start Position and Pin the objects in different modes such as Angle, Rope, Bar style and I can't make it work like I imagine.

    The idea is kind of simulating the same effect of the arrow in Hearthstone. I already did the example of the nice tutorial posted 2 years ago but it does not have the curve effect that I try to reproduce with animation.

    Thank you if you have any idea

  • So... marching ants!

    I don't have an exact answer or time to work on this now... but if I were to try this, I think I would start with a lerp function for a straight line movement, and a qarp function for a curved line.

    Here's a reference -

  • Any help is always welcome

    Thanks, I will take a look at it.

  • So... marching ants!

    I don't have an exact answer or time to work on this now... but if I were to try this, I think I would start with a lerp function for a straight line movement, and a qarp function for a curved line.

    Here's a reference - what-are-lerp-qarp-and-cubic-for-the-nonmath_t64198

    Hey Oosyrag,

    I tried different approaches with lerp and qarp, I still meet the same issue. Because my object (Bars) has a Bullet behaviour, when their angle change toward the new direction, they rotate from their pivot point. I don't know how to find a way to make them rotate from the same another point. I tried with Pin behaviour, creating a dummy object so I can pin my spawned object. But here again, they rotate around their image point (pivot).

    Here is a capx of what I tried for example:

    https://www.dropbox.com/s/4yi7141gezw77 ... .capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, I gave up trying to spawn new objects. I found another solution by using animation.

    I just Set Angle as already described and I set Width to distance(Startposition / Endposition) and play an animation in loop.

    Yes, it slightly deforms the blocks of the animation because we scale the width but the feel is there.

    I'm also thinking having different animations triggered by the distance in order to keep the blocks on the same size but, I don't know if it really requires it!

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