for cubes I'm just adding them to a group, I'm not doing anything with this group as of yet.
This is for moving player:
if Input.is_action_pressed("move_forward"):
direction.z = -1
if Input.is_action_pressed("move_backward"):
direction.z = 1
if Input.is_action_pressed("move_left"):
direction.x = -1
if Input.is_action_pressed("move_right"):
direction.x = 1
var camera_rotation = camera.rotation_degrees.y
direction = direction.rotated(Vector3.UP, deg_to_rad(camera_rotation))
if direction != Vector3.ZERO:
var movement_force = (direction.normalized() * speed) * state.step * 50
apply_central_force(Vector3(movement_force.x, 0, movement_force.z))
var horizontal_velocity = Vector2(linear_velocity.x, linear_velocity.z)
if horizontal_velocity.length() > max_speed:
horizontal_velocity = horizontal_velocity.normalized() * max_speed
linear_velocity.x = horizontal_velocity.x
linear_velocity.z = horizontal_velocity.y
else:
linear_velocity.x *= movement_damping
linear_velocity.z *= movement_damping```