Trouble with local cords and particles

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By DelicousPy

So in my top down shooter game I want particles to shoot in the direction that the gun (kinematic body) is facing, but the problem is the particles stay with the rotation of the gun. And before anyone comments about Local Coords, whenever I flick that off it doesn’t go in the direction of the gun at all, how can I make it so the particles shoot out in the direction of the gun, but then act independently and do not follow what where the gun later rotates?

PS:
Originally I tried to set the rotation degrees like so:
(Particle instance).rotation_degrees = (gun’s).rotation_degrees
But that method did not seem to work

Are the particles parented to the gun? Ideally they’d be independent of the gun and move using their own scene tree.

spaceyjase | 2023-06-12 10:16

Well originally they weren’t, I used something like this to spawn them independently:
Var Particle_instance = root of the particle.instance
Particle_instance.rotation_degrees() = gun.rotation_degrees
Particle_instance.global_position = gun.global_position
use get_tree().get_root(). call_deffered(“add_child”, particle_instance)
But for some reason this made it so they just kinda did whatever they wanted and wouldn’t emit in the rotation of the gun, so now they ARE parented to the gun when they spawn, which obviously isn’t ideal but it’s literally the only way I can get them to at least fire in the direction of the gun. Now the obvious issue with this is that when you move the gun, well, the particles will move too. But that’s where I’m stuck, if it’s patented to the gun then it’s obviously going to act as the guns child, but if it’s spawned independently it refuses to abide to any rotation i set for it through its spawning. And flicking off local cords one either of these just make the particles shoot how they would in their own scene.

DelicousPy | 2023-06-13 06:03