For player feedback we add sparks to the world where the bullet hit.
Add a New Scene with GPUParticles3D as root
Add an AnimationPlayer node as a child
In the Draw Passes property
Set Pass 1 tot a New BoxMesh
Set size to 0.1m on X, Y and Z
Click on the BoxMesh to expand
Find the Material property
Add a new StandardMaterial3D
Click on the sphere to expand it
Find the Emission property
Set Emission to a bright yellow
Set Energy Multiplier to 3.0
Exit the Draw Passes Property
Find the Process Material Property
Add a New ParticlesProcessMaterial
Click on it to expand further properties
Expand the velocity property
Set Direction to 0 on all axes
Set Spread to 180 to fire in all directions
Since this picks a random angle between 180 and -180 to spawn a particle
Set initial velocity to between 1.0 and 5.0
Expand the Display property
Expand the Scale property
Set the scale to between 0.5 and 1.0
Find the Scale Curve property
Fade particles out over time
We will instantiate sparks when we collide with something in the HitScanWeapon Script
In the HitScanWeapon Script
Export the sparks as a PackedScene
Quick Load the Sparks scene
Double-check that it gets assigned
By opening the Player scene
Assign it here if it is not present
In the HitScanWeapon script
Instantiate (create) sparks
Add them as a child to the scene tree
position them at the point of collision
Select the AnimationPlayer Node
Create a New Animation called spark
Select the Emitting property to true
Hit the Key to add it to the timeline
Also create the Reset track
Move to 1 second on the timeline
Right click on the Call Method Track
Call the function queue_free()
Set the Animation to AutoPlay
When you test your game, sparks should fly when bullets impact the world