Encountered issues while developing tower defense games

Godot Version

godot 4.3 beta 1


I am currently working on a tower defense game and I want my turret to point towards the monster as a whole (this feature has already been implemented). However, I want the weapons on the turret to aim at the monster around the x-axis. I have tried many methods but have not been able to achieve this feature.


func look_at_y1(self_node,targetNode):
	var target_position=targetNode.global_position
	var angle=lerp_angle(self_node.rotation.y,atan2(target_position[0]-self_node.global_position.x,target_position[2]-self_node.global_position.z),1)	

I would just do this in some form or fashion


But I don’t know how your nodes are arranged I assume the pumpkin is looking at the target just in the y axis. Then the rocket pods will only swivel on the x axis?

Is it all one node?

Does each node control itself or do we have to call get_node()?

1 Like

If they are separate nodes you could split up/move the rotation after a look_at


$Turret.rotation.x = rotation.x
rotation.x = 0

Thank you for your reply.

The components of the pumpkin turret can be disassembled, and the structure is as follows:

I have tried the look-at function and it works well when run alone, but when I rotate the entire turret around the y-axis and the weapon around the x-axis, the rotation angle of the weapon is very strange.

I just hope that while the turret can rotate itself, the weapon can aim up and down, just like when I stand in place and rotate, my arms can also swing up and down, which is the function I want to achieve.