godotengine / godotengine/godot

Basis.Rotated doesnt give the same value between GDScript and C#

Open
#87,799 9 comments 0 reactions 0 assignees View on GitHub
needs testing topic:core topic:dotnet topic:gdscript
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

### Tested versions

This was tested in godot 4.2.1 mono and standard build (for GDScript)

### System information

Windows 11, 4.2.1 stable, Vulkan Forward+

### Issue description

I am creating two vectors, one for pos, one for rotation. And i'm getting the transform out of that pair.
The resulting transform is correct on GDScript, and Incorrect on C# for some reason.

Outputs are
```
C#: [X: (1,1046701E-06, -0,99999994, 0), Y: (0,99999994, 1,1046701E-06, 0), Z: (0, 0, 1)]
GDScript: [X: (0.000001, -1, 0), Y: (1, 0.000001, 0), Z: (0, 0, 1)]
```

I think it all comes down to underlying types (I read somewhere that GDScript floats are 64 bits, whereas C# floats are 32),
or I might have missed something in my examples.
Please provide my poor brain with answers
Best regards
I attached a MRP.

### Steps to reproduce

Just run the MRP to get a perfect repro

### Additional insights

Just for going further, I put the code that transform two Vector3 given in params and outputs a transform in gdscript, that i called from C#, and interestingly, the result was similar to the one i got in native C#. Which definitely goes in the direction of wrong underlying types.

### Minimal reproduction project (MRP)

[GDBUG.zip](https://github.com/godotengine/godot/files/14117864/GDBUG.zip)

Contributor guide

Open the contributing guide

Research direction

Start by downloading and running the attached GDBUG.zip minimal reproduction project, then compare the C# and GDScript transform outputs described in the issue. Trace how the two Vector3 values are converted and how the transform is produced; done means identifying and correcting the source of the differing results, with the reproduction confirming consistent output.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.