Issues with hit scan particles. They spawn at LAST position?

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:
	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.global_position = ray_cast_3d.get_collision_point()

Important: does this only happen when shooting into the void after shooting something solid? If so, Bram fixes this later in the course, although I don’t remember exactly where. I’m pretty sure it’s not the final polish lecture at the end of the course though.

It’s also a pretty simple fix, but I won’t spoil it for you ^v^

(unless you run into difficulties of course)

To answer you query, yes, ONLY when shooting into the void after a colliding shot is landed. I think I may know what the fix you speak of is and want to test a bit on my own before being handed the answer by Bram. :slight_smile:
Also, thank you for sharing that a fix may be coming later!
SO far I am loving this course, much more in depth and explanatory than the other GODOT related content I have been digesting. Can’t wait for more courses and thrilled to have found out about the community here!

1 Like

That’s excellent! I’m also glad you found a great fit with these courses and the community =)

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms