Changed the way the rotation of a curve at a point is evaluated to match PathFollow2D

This commit is contained in:
Andrés Botero
2023-06-17 14:28:05 -05:00
parent f497156e0b
commit acae382010
4 changed files with 36 additions and 18 deletions

View File

@ -107,16 +107,14 @@
<param index="0" name="offset" type="float" default="0.0" />
<param index="1" name="cubic" type="bool" default="false" />
<description>
Similar to [method sample_baked], but returns [Transform2D] that includes a rotation along the curve, with [member Transform2D.origin] as the point position, [member Transform2D.x] as the sideways vector, and [member Transform2D.y] as the forward vector. Returns an empty transform if the length of the curve is [code]0[/code].
Similar to [method sample_baked], but returns [Transform2D] that includes a rotation along the curve, with [member Transform2D.origin] as the point position and the [member Transform2D.x] vector pointing in the direction of the path at that point. Returns an empty transform if the length of the curve is [code]0[/code].
[codeblock]
var baked = curve.sample_baked_with_rotation(offset)
# This will rotate and position the node with the up direction pointing along the curve.
# The returned Transform2D can be set directly.
transform = baked
# You can also read the origin and rotation separately from the returned Transform2D.
position = baked.get_origin()
rotation = baked.get_rotation()
# Alternatively, not preserving scale.
transform = baked * Transform2D.FLIP_Y
# To match the rotation of PathFollow2D, not preserving scale.
transform = Transform2D(baked.y, baked.x, baked.origin)
[/codeblock]
</description>
</method>