Hello everyone.
I'm new to Godot, and I'm trying to create a simple 3d game.
My goal is to recreate as accurately as possible a zero gravity fps.
I have set gravity to zero, set the linear and angular dump to -1 (and also run a test with zero), added a physic material with friction set to zero and set default linear and angular dump to -1 in the project setting/physic tab.
My player is a rigid body, and it starts with zero velocity, without any ground plane under his feet, just an empty space all around.
Then, I apply an impulse and the character start to accelerate.
The problem is that, If I stop to apply impulse, the character slowly start to decelerate and sooner or later it comes to a full stop. This is obviously not correct, he should keep the speed acquired forever until external forces are applied.
Can you please tell me what shoul I do to correct this issue?
Thank you in advance!
Here is the simple (and probably bad) code I'm using:
extends RigidBody
var M_force = 0.1
var Torque = 0.1
var forward
var right
var up
var orientation = Vector3()
func _ready():
pass # Replace with function body.
func _process(delta):
forward = -get_transform().basis.z
right = get_transform().basis.x
up = get_transform().basis.y
if Input.is_action_pressed("F_left"):
apply_central_impulse(right * -M_force)
elif Input.is_action_pressed("F_right"):
apply_central_impulse(right * M_force)
if Input.is_action_pressed("F_forward"):
apply_central_impulse(forward * M_force)
elif Input.is_action_pressed("F_backward"):
apply_central_impulse(forward * -M_force)
if Input.is_action_pressed("F_up"):
apply_central_impulse(up * M_force)
elif Input.is_action_pressed("F_down"):
apply_central_impulse(up * -M_force)
if Input.is_action_pressed("Yaw_Left"):
apply_torque_impulse(up * Torque)
elif Input.is_action_pressed("Yaw_Right"):
apply_torque_impulse(up * -Torque)
if Input.is_action_pressed("Pitch_Up"):
apply_torque_impulse(right * Torque)
elif Input.is_action_pressed("Pitch_Down"):
apply_torque_impulse(right * -Torque)
if Input.is_action_pressed("Roll_Right"):
apply_torque_impulse(forward * Torque)
elif Input.is_action_pressed("Roll_Left"):
apply_torque_impulse(forward * -Torque)