Hit a Moving Target - Godot 3D Tutorial - Trajectory and Aim - Code and Math
Channel: Neal Holtschulte
Date: 26/01/2024

#gamedev #godot #godot4 

00:35 The Code
03:01 The Math
11:02 The Scene
13:32 Q&A
15:19 Bugs

I'll show you how to calculate the point to shoot at in order to hit a moving target. I am not using hitscan weapons. No raycasts are used. All projectiles move through space over time.

This works in 2D and 3D. I'll demonstrate using Godot 4.2 in 3d and I will explain the math. There's also a surprisingly detailed discussion of our choice of bullet scene root node and how to apply decals.

Link to github page of the Godot project:
https://github.com/nealholt/TargetLeadExample
Link to a zip file of the Godot project:
https://drive.google.com/file/d/1Rwb3f9kYoSLb8D-CsMd4EQi9fvrqDQ6q/view?usp=sharing

Free assets used are available here:
https://kenney.nl/assets/blaster-kit
and here:
https://www.freepngimg.com/download/bullet%20hole/20-bullet-shot-hole-png-image.png

For the bullet hole decals I used moeDev's "How to Create Improved Decal/Bullet holes In Godot 4." tutorial: 
https://www.youtube.com/watch?v=8vFOOglWW3w

Dot Product Properties:
https://en.wikipedia.org/wiki/Dot_product#Properties