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.
thanks
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)
self_node.rotation[1]=angle
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()?
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.