So after adding the new rifle to the game I noticed an issue with the particle effect for the bullet impacts, it now holds the last location hit and repeats there, particularly when shooting into a void.
if aiming at a collision enabled surface the particles hit the location as expected but when I shoot into the air for example the particle effect plays at the last location that it collided with.
Is this normal behavior in this instance? Is there a setting or code to prevent this? I ask because let’s say I add a shotgun with a 30m maximum range and shoot at a wall 50m away I don’t want the effects spawning on the rock next to the player if that’s the last thing they shot at.
I would be happy to add addtional code/screenshots if requested, but I am not sure WHAT code would be needed here.
Here is the chunk from the “shoot” function in SMG script which I think is the place where the issue would occur.
func shoot() -> void:
muzzle_flash.restart()
bullet_tracer.restart()
cooldown_timer.start(1.0 / fire_rate)
var collider = ray_cast_3d.get_collider()
printt("weapon fired!", collider)
weapon_mesh.position.z += recoil
if collider is Enemy:
collider.hitpoints -= weapon_damage
var spark = sparks.instantiate()
spark.restart()
add_child(spark)
spark.global_position = ray_cast_3d.get_collision_point()