Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KinematicBody2D Move and Collide crashes game #52

Open
Trey2k opened this issue Mar 25, 2021 · 0 comments
Open

KinematicBody2D Move and Collide crashes game #52

Trey2k opened this issue Mar 25, 2021 · 0 comments

Comments

@Trey2k
Copy link

Trey2k commented Mar 25, 2021

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
@Trey2k Trey2k changed the title KinematicBody2D Move and slide crashes game KinematicBody2D Move and Collide crashes game Mar 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant