My 3d movement is not... y'know, moving?

Godot Version



As said in the title, nothing is moving, I know it is moving because my shadow is shivering, but its almost like my ground is connected to me

extends CharacterBody3D

const SPEED = 5.0
const JUMP_VELOCITY = 4.5

Get the gravity from the project settings to be synced with RigidBody nodes.

var gravity = ProjectSettings.get_setting(“physics/3d/default_gravity”)

func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta

# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
	velocity.y = JUMP_VELOCITY

# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector("ui_left", "ui_right", "ui_up", "ui_down")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
	velocity.x = direction.x * SPEED
	velocity.z = direction.z * SPEED
	velocity.x = move_toward(velocity.x, 0, SPEED)
	velocity.z = move_toward(velocity.z, 0, SPEED)


Just tried it here and worked fine, using a CharacterBody3D with all default settings and a basic recreation of your scene here. The inputs came in fine, translated to a direction fine, and moved the body around fine. So I dunno, I’d say maybe double check that everything is back on default values and try again.

It might help to see the characterbody3d’s properties like if that object was selected in your screen shot.

Tried one other thing here, no change, i can’t get the script to not work as expected even if I try to break it with weird settings on other objects.

Make sure your SPEED variable is valid. (edit: and Time_Scale, make sure that’s not 0 somehow)

You are using the “ui_” builtin actions, are you using the arrow keys to move?

Nope, remapped to WASD in the input map

Another thing, i have a big flat piece to orient myself and i cant see it, so i think my godot is being odd

Try the arrow keys. In your code where it says “ui_left” etc, that’s referring to special internal versions of up/down/left/right used for navigating menus. You won’t see them in the list of actions unless ‘Show Built-In Actions’ is enabled.

or change that line to read more like:

var input_dir = Input.get_vector("Left", "Right", "Forwards", "Backwards")
1 Like

i did fix it, turns out i had another different faulty program in the background, the code worked the second i closed that one

1 Like