ShadowApex / godot-go

Go language bindings for the Godot Engine's GDNative API.
MIT License
363 stars 31 forks source link

KinematicBody2D Move and Collide crashes game #52

Open Trey2k opened 3 years ago

Trey2k commented 3 years ago

Description

When calling the MoveAndCollide function for the kinematicBody2D the game crashes right after launch with no error, the code snippet below works fine with the line commented out. I can just set the position but collisions will not be calculated then.

// X_Process is called every frame
func (r *Robot) X_Process(delta gd.Real) {

    velocity := gd.NewVector2(0, 0)

    if godot.Input.IsActionPressed("ui_right") {
        velocity.SetX(velocity.GetX() + 1)
    }
    if godot.Input.IsActionPressed("ui_left") {
        velocity.SetX(velocity.GetX() - 1)
    }
    if godot.Input.IsActionPressed("ui_down") {
        velocity.SetY(velocity.GetY() + 1)
    }
    if godot.Input.IsActionPressed("ui_up") {
        velocity.SetY(velocity.GetY() - 1)
    }

    if velocity.Length() > 0 {
        normal := velocity.Normalized()
        velocity = normal.OperatorMultiplyScalar(speed)
    }

    r.MoveAndCollide(velocity.OperatorMultiplyScalar(delta))
}

Details

Go version 1.16.2
Godot version 3.2.3
Godot-Go version/commit hash Current
OS Arch Linux 5.11.6