0 votes

I've got a function working fine, using global transforms:

var T = base.get_global_transform()
var p1 = T.origin
var p2 = p1 + T.basis.x
var p3 = p1 - T.basis.z
var plane = Plane(p1, p2, p3)
var look_at = plane.project(globalTarget)
var z = -(look_at - p1)
var y = T.basis.y
var x = y.cross(z)
var finalTransform = Transform(Basis(x, y, z), p1).orthonormalized()
base.set_global_transform(finalTransform)

I'm now trying to work in local transforms, to handle limits on movement. But it does not work at all:

var T = base.get_transform()
var p1 = T.origin
var p2 = p1 + T.basis.x
var p3 = p1 - T.basis.z
var plane = Plane(p1, p2, p3)
var look_at = plane.project(base.to_local(globalTarget))
var z = -(look_at - p1)
var y = T.basis.y
var x = y.cross(z)
var finalTransform = Transform(Basis(x, y, z), p1).orthonormalized()
base.set_transform(finalTransform)

Is there anything else I should be doing to use local transforms instead of global transforms?

in Engine by (17 points)

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.