godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
86.55k stars 19.28k forks source link

New `lerp()` method has unhelpful error messages #64332

Open aaronfranke opened 1 year ago

aaronfranke commented 1 year ago

Godot version

master as of #60924

System information

N/A

Issue description

I'm getting this error when one argument is a float and one argument is an int. The error message is confusing because it looks like it's trying to convert to nil. I assume it's triggering the if (from.get_type() != to.get_type()) { condition in the PR, and the solution is simply for me to switch to lerpf and/or cast my inputs to float, but it's poor UX right now.

Screen Shot 2022-08-12 at 12 07 21 PM

Another small problem I noticed with lerp() is that the weight is currently a Variant, but it should be a float (double). It's strange that it shows up as a Variant, because the method argument has the correct type.

Steps to reproduce

var x: int = 1
lerp(0.0, x, 0.5)

Minimal reproduction project

Paste the above code snippet into any Godot project.

infohub-gather commented 1 year ago

I am justing putting this under this report, maybe it is related. I have a simply lerp function : freq_low = lerp(min_freqs, max_freqs, freqs_low)

It was working perfectly in A13, but now throws an error : "Invalid Call. Nonexistent Utlity Function 'lerp' "

I checked if there are any changes to the helpdocs or issues, but apparently not so this must be a bug.

yaelatletl commented 1 year ago

Found out the lerp function complains a lot if one of the arguments is not the same type as the others. ~Ex. (int, int, float) or (float, int, float) It works with either (float, float, float), or (int, int, int)~ Edit: As aaronranke said on the response, only the two first need to match

aaronfranke commented 1 year ago

@yaelatletl Only the first two arguments need to match, since the weight is always a float (C++ double).

jcarlosrc commented 1 year ago

It sometimes also happens event to floats, apparently randomly. I had to implement my own function my_lerp(a, b, t) : a + t(b-a) to avoid the error.

Sammyjroberts commented 1 year ago

Hi there, I got this same issue, definitely related to the first 2 arguments matching, should a better error message be thrown, or should we try to convert better? I'd be willing to take a shot trying to fix the issue if there is a decision on what should be done

Calinou commented 1 year ago

Hi there, I got this same issue, definitely related to the first 2 arguments matching, should a better error message be thrown, or should we try to convert better? I'd be willing to take a shot trying to fix the issue if there is a decision on what should be done

The Godot 3 -> 4 project converter is not aware of the arguments' types (it only performs text replacement). This means it unfortunately can't replace lerp() with lerpi() or lerpf() when possible.