neikeq / GodotSharp

Moved to the Godot repo: https://github.com/godotengine/godot/tree/master/modules/mono
MIT License
60 stars 8 forks source link

Functions that get or set Vector3 don't recognize Z #25

Closed NathanWarden closed 7 years ago

NathanWarden commented 7 years ago

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))
NathanWarden commented 7 years ago

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?

terahlunah commented 7 years ago

I think I found the issue, I haven't had the time to test it yet though, still setting up everything

NathanWarden commented 7 years ago

@terahxluna Thanks! :)

terahlunah commented 7 years ago

A pleasure to help out when I can ;)