This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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?

in Engine by (33 points)

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.

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.