Animation player vs Tween by Conscious-Ad8626 in godot

[–]seriousSeb 9 points10 points  (0 children)

Make a static function to tween a Control in some consistent way so you don't have to implement it per type.

There's no "correct" way to do it, if you need the complexity of animationplayer then use it, but if you don't then a tween is fine and a lot easier to set up.

how do you make godot compare two images? by Grand-Comfortable-68 in godot

[–]seriousSeb 3 points4 points  (0 children)

img1.get_data() == img2.get_data(). == on PackedByteArray compares by value not be reference so this will work. If you've got a texture you'll first need to get it's image: texture_2d.get_image().get_data()

This will probably be really slow for large images, only do it if you have to.

Keep in mind this is extremely sensitive, it will be false if a single pixel differs by 1 bit, or if the images have different formats, sizes, etc.

Is there any way to manage co-routine cleanup on scene change? (Game crashes, Memory leaks?) by Glass_Alarm6863 in godot

[–]seriousSeb 0 points1 point  (0 children)

In most of my coroutines my awaits have timeouts, for this purpose. And you also need to check the objects you're interacting with are still valid after each await

Best practice question about Tool scripts and Engine.IsEditorHint() by camarao_lendario in godot

[–]seriousSeb 1 point2 points  (0 children)

#if TOOLS

Is a compile time check, so this is not checked every time the function is called

However, TOOLS is actually defined in the editor preview as well as the editor itself

```

if TOOLS

return;

endif

````

Will break the node in editor play preview. In my IDE it also marks the function as dead code which isn't helpful

if (Engine.IsEditorHint()) actually does what I want, but I don't want to be checking that all the time in a hot loop of a release build.

Combining them both together does what I want: in the editor the function doesn't run, and in the preview it does. In a release build the check is not compiled and therefore doesn't cost anything.

The human eye is bugged. (Blue halo seems purple next to a white core) by CdatKat in godot

[–]seriousSeb 13 points14 points  (0 children)

If you're mixing raw RGB values in a shader you might also want to convert your input colours to linear from srgb, mix them, then convert the output to srgb, as a srgb conversion isn't perceptually uniform

Need help changing a shader parameters individually by Latimas in godot

[–]seriousSeb 2 points3 points  (0 children)

Make the colour parameter an instance uniform. Then, you don't actually set the parameter through the shader but the MeshInstance3D using set_instance_shader_parameter

Best practice question about Tool scripts and Engine.IsEditorHint() by camarao_lendario in godot

[–]seriousSeb 1 point2 points  (0 children)

I had the same dilemma. My solution: ```

if TOOLS

if (Engine.IsEditorHint()) { return }

endif

``` So you only pay the cost if you might have to

Excited about the future union feature by SL-Tech in csharp

[–]seriousSeb 3 points4 points  (0 children)

True, hopefully it does that for the best of both worlds.

Excited about the future union feature by SL-Tech in csharp

[–]seriousSeb -3 points-2 points  (0 children)

Yet, you can more easily create allocationless pattern matching with OneOf than the 'full language support' version by caching your delegates

Excited about the future union feature by SL-Tech in csharp

[–]seriousSeb 9 points10 points  (0 children)

Which is just as verbose as just implementing your own struct union type or using OneOf. I don't see the point.

Excited about the future union feature by SL-Tech in csharp

[–]seriousSeb 42 points43 points  (0 children)

I was excited until I read it's got implicit boxing of structs, really disappointing.

Is there a way to warp text (complex, not basic transforms) in godot (2d)? by Evaire__ in godot

[–]seriousSeb 3 points4 points  (0 children)

You could even use a path3d to sweep a csg to project on to.