I'm trying to mimic the tracer effects you see in most modern shooters, what's the best way to achieve accuracy with the tracers so that it follows your raycast and in an efficient way? I'm wondering because I'm using add_child to put in a tracer particle effect.

extends Spatial

var tracerScene = preload ("res://GlockTracer.tscn")
onready var localPlayerHead = get_node("..")

func _ready():
	print (get_node("..").name)

var Timer = 0

func _process(delta):
	Timer -= 0.015
	
	if Input.is_action_pressed("Fire") and Timer <= 0:
		var tracerInstance = tracerScene.instance()
		get_tree().get_root().add_child(tracerInstance)
		tracerInstance.global_transform.origin = global_transform.origin
		tracerInstance.rotation = localPlayerHead.rotation
		tracerInstance.emitting = true
		Timer = 1.0

Another problem I ran into is that despite me setting the rotation to try and match the player's head the rotation seems to be ignored? Is it because of me adding the child to the root node first or something? Would appreciate some input on that extra problem.

Oh for crying out loud had another classic where I post a question and then find the answer online.

https://kidscancode.org/godot_recipes/3d/3d_shooting/

Need to refind my keyword searches because Godot 3D vs Godot brings up some quite different results. Does anyone know though if this is necessarily efficient for making tracers? I keep wondering if there's a better way.

achieve accuracy do you mean the bullet drop? Use parabola or similar equation graph.

so that it follows your raycast Follow the parabola graph then fire short raycast ray which origin is on the graph(the point should be at the middle of the ray, but that is too little detail, better just ignore it) and direction from slope of parabola at that point.

with the tracers Either do projectile bullet with trail that follow bullet like you already done it. Or if it is hit scan, I think it is better to do shader stuff.

match the player's head the rotation seems to be ignored? Because Spatial.rotation return local rotation, which I think you rotate body object and head follow its parent. So when body is rotated, the local space head is still not rotate. Use world space for rotation reference Spatial.global_transform.rotation. And rotation I think it is better to use camera rotation if it is fps or tps or if it is top down, direction of character to mouse.

where I post a question and then find the answer online You research before you post and still research after post, sometime you just miss something from your research, do not gonna blame you and this question is not common; on the other hand, if you don't do research and ask really common question...

Need to refind my keyword searches because Godot 3D vs Godot brings up some quite different results Not true, no need to refine. This result might be found in later page. But to do is to remember more keyword you found and search them in order with priority that you think which one might yield better result.

Oh yes, found a much better tutorial for my needs This tutorial is 2d, right? And your project is 3d. Did you adapt from tutorial? Nice job.

Thanks very much for the extra information there and I figured given the size of my FPS project it probably won't matter too much with the tracers performance wise if I delete them after fast enough. I'm just thinking in terms of long term projects and scalability.

I've traditionally used Unity and have been learning that for almost 5 years now and still use it for a main project I'm doing. I wanted to see if I could go open source though for various reasons with my software as much as possible and I've been learning about Godot's strange quirks compared to Unity. As you point out, it seems to be much fussier than Unity in how it deals with the local vs global transforms and so on and I'm having to work that out so what you posted has been helpful in understanding everything properly. I also hadn't noticed how much some of the syntax in GDScript changes with 2D vs 3D so that's another thing I'll have to keep an eye out for when looking at tutorials.

As for shaders, I'm not sure how much the performance would change with that compared to using a simple quad like I have. I like tracer effects a lot so I may even make the particles into cylinder meshes to prevent any weirdness with viewing them from multiple angles. I'll just have to experiment and use the debugging tools to check the performance impact when I really get these tracers firing off.

I'm just thinking in terms of long term projects and scalability. I am should not be the one who say this, but here I am; You should not think about optimize too early, unless you found it and easy to fix or it is critical problem.

if I could go open source You can opensource your Unity project, well it is strange sometime. Or did I misunderstand your statement?

how it deals with the local vs global transforms Unity also has the concept of local and global space, or reference to other object's local space. Well, Godot... has local space but global space is kinda exist and not at the same time. :s

some of the syntax in GDScript changes with 2D vs 3D No, they are same. Just difference node type Node2D and Spatial. In same scene can also have both type coexist. one with (3D)Camera and another Camera2D. Or just bridge this 2 things with Viewport node.

As for shaders, I suggest this because I think it can look better than traditional way, not performance.

compared to using a simple quad Why don't use Particle node? I never use this node but I bet it is not too difference from Unity's particle.

2 years later