Physics - Set arrows angle to follow path

For questions about using Classic.

Post » Wed Dec 14, 2011 9:24 pm

Hi All

Ive checked examples and posts and cant really find a way to solve my problem.

I want to fire and arrow like angy birds style. (ive solved that)
BUT i want the arrow tip to follow the flight path.

I use add force to launch the arrow (i need physics in my test game) but i dont know how to set the angle. Do you use torque in some way?

B
3
G
1
Posts: 7
Reputation: 489

Post » Fri Dec 16, 2011 7:28 pm

Here is a cap to show what im trying to do. Hope someone has an idea or workaround on how to get the arrow to rotate with the trajectory.

Cap test fileOmnige2011-12-16 19:28:52
B
3
G
1
Posts: 7
Reputation: 489

Post » Fri Dec 16, 2011 10:51 pm

A few things to mention:
You can't directly change the angle of the object (just as you can't directly change the position of the object) without breaking the physics behavior.
The sprite was drawn with facing up as initial state. But initially all sprites are at 0, which is facing right.

To get the rotation just add a second sprite, set it to always be at the first sprite's position and cache the last position. Then just set the angle of the second sprite to the angle between the last and actual position.

Here is an example: phys_Angle.cap
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Sat Dec 17, 2011 12:34 am

That is a brilliant workaround. Thank you.

I just removed the physics behaviour from the second arrow, cause it was multiplying the effect and was too speedy. :)

Its is to bad though that you cant change the angle without stoping the physics behaviour. Could have been cooler if you could apply force and angle while it was moving and not stopping.

Thanks again:)
B
3
G
1
Posts: 7
Reputation: 489

Post » Sat Dec 17, 2011 12:43 am

[QUOTE=Omnige] I just removed the physics behaviour from the second arrow, cause it was multiplying the effect and was too speedy. :)[/QUOTE]
My bad. It wasn't intended, I just forgot to remove it after duplicating the original sprite :)

I'm glad that it was of help.

With physics and angles: Don't forget that there's friction and the like, so objects need to be rotated physically correct on contact by the engine - that's why rotating an object manually would break it.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests