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?