summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-09-29 15:34:08 +0200
committerRémi Verschelde <rverschelde@gmail.com>2022-09-29 15:34:08 +0200
commit7c7a86f0fd0c1ae94099f2c1fdd878ab60dcb077 (patch)
tree452c71edfa177bbbdd2181718880e13b0f4499c3
parent176da47ffdd8fea540ffce006d143544b033ce26 (diff)
parentc080b9dc05d57cf9363d8fcde42689c943387607 (diff)
Merge pull request #66592 from KoBeWi/look_at_me_I_am_the_captain_now
Fail `look_at()` if not inside tree
-rw-r--r--doc/classes/Node3D.xml2
-rw-r--r--scene/3d/node_3d.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/doc/classes/Node3D.xml b/doc/classes/Node3D.xml
index 96ce10745d..3df7ec931f 100644
--- a/doc/classes/Node3D.xml
+++ b/doc/classes/Node3D.xml
@@ -116,7 +116,7 @@
Rotates the node so that the local forward axis (-Z) points toward the [param target] position.
The local up axis (+Y) points as close to the [param up] vector as possible while staying perpendicular to the local forward axis. The resulting transform is orthogonal, and the scale is preserved. Non-uniform scaling may not work correctly.
The [param target] position cannot be the same as the node's position, the [param up] vector cannot be zero, and the direction from the node's position to the [param target] vector cannot be parallel to the [param up] vector.
- Operations take place in global space.
+ Operations take place in global space, which means that the node must be in the scene tree.
</description>
</method>
<method name="look_at_from_position">
diff --git a/scene/3d/node_3d.cpp b/scene/3d/node_3d.cpp
index ebf26996dd..12d2e66b41 100644
--- a/scene/3d/node_3d.cpp
+++ b/scene/3d/node_3d.cpp
@@ -786,6 +786,7 @@ void Node3D::set_identity() {
}
void Node3D::look_at(const Vector3 &p_target, const Vector3 &p_up) {
+ ERR_FAIL_COND_MSG(!is_inside_tree(), "Node not inside tree. Use look_at_from_position() instead.");
Vector3 origin = get_global_transform().origin;
look_at_from_position(origin, p_target, p_up);
}