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.