Functions that get or set Vector3 don't recognize Z
NathanWarden opened this issue · 4 comments
I'm not sure why, but when using methods like get_translation/set_translation or get_rotation/set_rotation the z value is always returned or set as zero.
Below is some sample code where I'm rotating a MeshInstance around the Z. Note that if I use the X or Y axis then it works as expected. The same is true for translation methods and I'm assuming for all other methods where Vector3 parameters are used.
Thanks :)
C# doesn't work with the Z axis
using GodotEngine;
public class TestScript : Spatial
{
float totalTime = 0.0f;
void _process(float delta)
{
totalTime += delta;
set_rotation(new Vector3(0, 0, totalTime));
}
}
GDScript works with the Z axis
extends Spatial
var totalTime = 0.0
func _process(delta):
totalTime = totalTime + delta
set_rotation(Vector3(0,0,totalTime))
Doing a little more investigation. If I Godot.print the entire Vector3 it doesn't see the z value and simply returns 0.
IE:
Godot.print(new Vector3(10, 10, 10)); // output is (10,10,0)
Godot.print(new Vector3(10, 10, 10) + new Vector3(5,5,5)); // output is (15,15,0)
However, if I explicitly access z instead it gives me the right number.
IE:
Godot.print(new Vector3(10, 10, 10)[2]); // output is 10
Godot.print((new Vector3(10, 10, 10) + new Vector3(5,5,5)).z); // output is 15
So, it must be that somehow z is getting dropped when passing the entire struct back to the C++ side?
I think I found the issue, I haven't had the time to test it yet though, still setting up everything
@terahxluna Thanks! :)
A pleasure to help out when I can ;)