mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 03:18:37 +08:00
Merge pull request #25093 from akien-mga/lerp-returns-variant
GDScript: Fix return value of "lerp" builtin
This commit is contained in:
commit
7ae4cb7f7d
@ -539,7 +539,7 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="lerp">
|
||||
<return type="float">
|
||||
<return type="Variant">
|
||||
</return>
|
||||
<argument index="0" name="from" type="Variant">
|
||||
</argument>
|
||||
@ -549,8 +549,11 @@
|
||||
</argument>
|
||||
<description>
|
||||
Linearly interpolates between two values by a normalized value.
|
||||
If the [code]from[/code] and [code]to[/code] arguments are of type [int] or [float], the return value is a [float].
|
||||
If both are of the same vector type ([Vector2], [Vector3] or [Color]), the return value will be of the same type ([code]lerp[/code] then calls the vector type's [code]linear_interpolate[/code] method).
|
||||
[codeblock]
|
||||
lerp(1, 3, 0.5) # returns 2
|
||||
lerp(0, 4, 0.75) # returns 3.0
|
||||
lerp(Vector2(1, 5), Vector2(3, 2), 0.5) # returns Vector2(2, 3.5)
|
||||
[/codeblock]
|
||||
</description>
|
||||
</method>
|
||||
|
@ -27,7 +27,7 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="collide_and_get_contacts">
|
||||
<return type="Variant">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<argument index="0" name="local_xform" type="Transform2D">
|
||||
</argument>
|
||||
@ -59,7 +59,7 @@
|
||||
</description>
|
||||
</method>
|
||||
<method name="collide_with_motion_and_get_contacts">
|
||||
<return type="Variant">
|
||||
<return type="Array">
|
||||
</return>
|
||||
<argument index="0" name="local_xform" type="Transform2D">
|
||||
</argument>
|
||||
|
@ -1565,7 +1565,8 @@ MethodInfo GDScriptFunctions::get_info(Function p_func) {
|
||||
} break;
|
||||
case MATH_LERP: {
|
||||
MethodInfo mi("lerp", PropertyInfo(Variant::NIL, "from"), PropertyInfo(Variant::NIL, "to"), PropertyInfo(Variant::REAL, "weight"));
|
||||
mi.return_val.type = Variant::REAL;
|
||||
mi.return_val.type = Variant::NIL;
|
||||
mi.return_val.usage |= PROPERTY_USAGE_NIL_IS_VARIANT;
|
||||
return mi;
|
||||
} break;
|
||||
case MATH_INVERSE_LERP: {
|
||||
|
Loading…
Reference in New Issue
Block a user