0 votes

Hello,
In my game I have a bow that fires arrows. The arrows are rigidbodies with a small elongated capsule covering the arrow shaft and have a raycast node the length of the arrow to detect when it hits. The terrain is a mesh with trimesh collider.

It works very well most of the time, but sometimes the arrow goes through the terrain. The hit is always detected. Here is the code used to fire the arrow:

var bowpower = -40
arrow.apply_central_impulse (arrow.get_global_transform().basis.z.normalized() * bow
power)

How can I prevent my arrow from going through the terrain ?

Thanks in advance

in Engine by (283 points)
edited by

1 Answer

0 votes
Best answer

This might be a simple "bullet through paper problem". Try to enable continuous collission detection (CCD) for the arrow.

https://docs.godotengine.org/en/3.1/classes/class_rigidbody.html#class-rigidbody-property-continuous-cd

by (64 points)
selected by

Thanks a lot, I don't know how I missed this option! :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.