Arrow , Projectiles

Godot Version

4.6 dev1 custom

Question

Hello ,

I wonder what nodes and code should I use to instantiate arrow ,

when hits enemy to stick to it and based on distance , speed cause damage .

if hits tree, ground just stick to it

Some tips to make physics which would reflect trajectory of arrow or projectile ?

a area2d would be the simplest solution. It can detect other physic-bodies so you can detect when it hits an entity.

If you want to make it stick you can reparent it to the target after it has been it, so it will inherit the targets position.

Regarding the trajectory: heres a great tutorial on calculating trajectory in a realistic manner

Its godot 3 but its easily convertable to godot 4

2 Likes

@iOSxcOder A helpful answer might depend on whether this was 2D or 3D, but in general it’s important to understand that physics bodies like RigidBody2D can be moved by the physics simulation, and the simulation will take care of trajectory. So, get the arrow in the scene and send it!

Reparenting the arrow to a static object like a tree is what I would do to make it “stick”. If the arrow lands on the ground, it will not move unless acted upon (Newton’s first law of motion).

If the damage the arrow causes is dynamic based on the arrow’s speed, use the speed of the arrow as a multiplier when calculating the damage. Damage being dependent on distance is an interesting question to me… it can be calculated, but does it need to be calculated by you?

Your questions give me a new one: does the Godot physics simulation manage things like a body’s change in momentum (ex. the force of an arrow diminishing over distance)?

1 Like

For your question, you can just hack it by changing the project settings gravity to have an x component.

Or you can assign a physics material to your “environment” to simulate air resistance or whatever you’d like. I don’t know how to do that but I’ve read something along the lines of this on the forum before.

1 Like

3D environment.

I’m interested in this momentum as this could be useful for other things then arrow - spears , throw knife , projectiles, darts , ball launched by cannon, catapult , thrown by giants etc.

4.6 came with some new things in bone system so maybe this could be combined with nodes , code , and some settings :thinking: