Godot Version
4.3
Question
I have been working on this problem for awhile now and am stumped. I have a boat (RigidBody3D) that I am trying to move with apply_central_force. Unfortunately, everything seems to be working except apply_central_force. Turning works and I am able to set the speed variable fine as well, but it seems like the one line where I apply force is simply being ignored. Here is the relevant code snippet I am working with from the boat’s script.
extends RigidBody3D
@export var controls:Resource = null
var speed := 0.0
var acceleration := 1000
var handling := 25
var turning = 0
func _process(delta: float) -> void:
turning = 0
turning += Input.get_action_strength(controls.move_left)
turning -= Input.get_action_strength(controls.move_right)
turning *= deg_to_rad(handling)
speed = 0
speed += Input.get_action_strength(controls.move_up)
speed -= Input.get_action_strength(controls.move_down)
speed *= acceleration
var new_basis = global_transform.basis.rotated(global_transform.basis.y, turning)
global_transform.basis = global_transform.basis.slerp(new_basis, 3 * delta)
global_transform = global_transform.orthonormalized()
func _physics_process(delta: float) -> void:
apply_central_force(global_transform.basis.z*speed)
global_transform.basis and speed both print out correct values in the physics_process function when I test, but the boat just does not move. Damping is set to 0 on the boat. I have tried using apply_force as well and had no luck.