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

Get help using Construct 2

Post » Thu Apr 14, 2016 12:26 am

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 :)
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Thu Apr 14, 2016 1:41 am

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
Mistakes were made.
B
52
S
26
G
108
Posts: 1,605
Reputation: 61,131

Post » Thu Apr 14, 2016 3:37 am

Any help is always welcome :)
Thanks, I will take a look at it.
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Thu Apr 14, 2016 5:51 am

oosyrag wrote: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
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Fri Apr 15, 2016 4:22 am

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!
B
26
S
10
G
3
Posts: 72
Reputation: 4,008


Return to How do I....?

Who is online

Users browsing this forum: adventurist, Blendi1223, newt, PROxMTswatTR, ST314, Yahoo [Bot] and 35 guests