0 votes

Hello, I trying to make space ship turret and need some help. What i have so far:

scene hierarchy image
and code:

func track_enemy(_entity, delta):

var t = turret_parent.get_global_transform()
var lookDir = _entity.get_global_transform().origin# - t.origin
var rotTransform = t.looking_at(lookDir, Vector3(0,1,0))
var thisRotation = Quat(t.basis).slerp(rotTransform.basis, value)
value += delta
if value >1:
    value = 1
turret_parent.set_global_transform(Transform(thisRotation, t.origin))

turret tower position in global space image

here is the player and white 'thing' on top of it is turret tower looking at the target (red line how it should be).

Any help what should I do to lock rotation just on y axis?
(I can't see posted images here is hierarchy image and space ship image)

in Engine by (106 points)
edited by

Ok I found work around - I made a simple position 3D node as dummy turret and set transform from code above and then turret_tower.set_rotation(Vector3(0,dummy_turret.get_rotation().y,0))

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.