How do I Arrow flight

Get help using Construct 2

Post » Tue Aug 04, 2015 1:26 pm

HI Guys,

I'm looking for action -- then Fire a "Arrow" with physics and a Denser Physic at the Arrow Head ---

I need to simulate the flight of the arrow.

When arrow's reaching max height
1. The edge of the arrow should fall first and only after the body of the arrow.

My arrow instead flight like peace of crap (fully solid object with center of the mass in the center). Dropping on body of the arrow first

I have broken my head already.

Do you have any Ideas?
B
19
S
6
G
1
Posts: 25
Reputation: 1,719

Post » Tue Aug 04, 2015 2:34 pm

If you're using the physics behavior, you can apply a torque to the arrow to make it straighten out towards the direction it's moving.
This torque should be greater the faster the arrow is moving. So, if it's sitting on the ground, no torque. If it's flying fast, lots of torque.

You can use the "Apply torque towards angle" action to get this effect.
It would look something like the following:

Apply torque towards angle:
  • Torque: 0.001 * arrow_speed
  • Angle: arrow_movement_angle
(The "0.001" just scales the amount of torque used to correct the arrow angle. You can experiment with it.)

Of course there are no "arrow_speed" or "arrow_movement_angle" values by those names, so you'll need to calculate that information, but fortunately that's not too hard.

We can get the speed by finding the length of the Physics behavior's velocity vector. We get the angle by finding the angle of the velocity vector.

Apply torque towards angle:
  • Torque: 0.001 * distance( 0 , 0 , arrow.Physics.VelocityX , arrow.Physics.VelocityY )
  • Angle: angle( 0 , 0 , arrow.Physics.VelocityX , arrow.Physics.VelocityY )

This should make arrows fly head first, but will still allow them to topple end-over-end if they bounce off of something and lose most of their speed.

This is not a perfect simulation of arrow flight, as it doesn't account for linear off-axis forces resulting from the separate center of gravity, and center of pressure, but for it's simplicity it is pretty close.

I actually just uploaded an update of a game I made that uses this exact method for handling arrow flight.
ArcherOpteryx: http://gamejolt.com/games/archeropteryx/45519
(note: Firefox runs it a little slow, but every other browser, and the desktop version run fine.)

Hope that helps out :)
B
27
S
18
G
8
Posts: 327
Reputation: 6,156

Post » Tue Aug 25, 2015 5:26 pm

thank you for your help Fisholith
B
19
S
6
G
1
Posts: 25
Reputation: 1,719

Post » Tue Aug 25, 2015 5:30 pm

I've got the solution based on your comment!!! Thank you very much again!

Here is the example:
Every 0.1 sec. - Arrow Set Angle: angle( 0 , 0 , arrow.Physics.VelocityX , arrow.Physics.VelocityY )

Easy and cosy
B
19
S
6
G
1
Posts: 25
Reputation: 1,719


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests