Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | swipis | |
Old Version | Published before Godot 3 was released. |
Hello, I trying to make space ship turret and need some help. What i have so far:
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))
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)
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))
swipis | 2017-11-07 17:14