Godot freezing after rotating?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ComLarsic

I have a RigidBody with a camera and a meshinstance as a child,
it rotates whenever i press a button.

when i rotate it it seems to work fine however after i rotate too much the physics engine just seems to stop.

heres my code(in C#):

using Godot; 
using System;

public class SpaceShip : RigidBody
{
Vector3 velocity = new Vector3();

float rotationX = 0;
float rotationY = 0;
float rotationZ = 0;
public override void _Ready()
{
    
}

// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _IntegrateForces(PhysicsDirectBodyState state)
{
    if(Input.IsActionPressed("movement_upward"))
    {
        velocity.y = 1;
    }
    else if(Input.IsActionPressed("movement_downward"))
    {
        velocity.y = -1;
    }
    else
    {
        velocity.y = 0;
    }

    if(Input.IsActionPressed("movement_backward"))
    {
        rotationX += 1;
    }
    else if(Input.IsActionPressed("movement_forward"))
    {
        rotationX += -1;
    }

    if(Input.IsActionPressed("movement_left"))
    {
        rotationY += 1;
    }
    else if(Input.IsActionPressed("movement_right"))
    {
        rotationY += -1;
    }
    
    
    RotateX(Mathf.Deg2Rad(rotationX));
    RotateY(Mathf.Deg2Rad(rotationY));
    state.ApplyCentralImpulse(velocity / 4);
}

}

is this a bug or am i doing something wrong?

i can not see an error , but in my case when godot freeze is because an infinite loop in the code… check all the code just in case is that.

Manuel | 2020-05-11 16:04