0 votes

In my game balls are thrown in towards the player by a turret. How can I make it so that if the player is ball's path a text is displayed on the screen? Newbie here, thanks in advance.

Godot version 3.4.2
in Engine by (12 points)

1 Answer

–1 vote

Is the turret also moving?

If so

How good is was your maths teacher? The rigorous way is to solve for the intersection vector through a series of linear equations using a iterative implementation of Gaussian elimination. Khan Academy covers it well but this is not a beginner's approach.

Otherwise, you can always just simulate. Every ten frames or so you could (asynchronously on a thread if you can) loop the movement and test if they get close enough to collide.

Otherwise, I can't think of an easy beginner way, sorry.

If not

Cast a raycast pointing in the forward velocity vector of the ball and and it'll tell you if it intersects with the turret.

by (2,152 points)
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.