Posted: 25th May 2023 2:11
I'm trying to get the character controller to move in the direction of my joystick, but it moves in one direction forever. Here's my code, there are no assets so it should be easy to test in an empty project:

+ Code Snippet
SetWindowTitle("3D Character")

Create3DPhysicsWorld()

player = CreateObjectCapsule(40, 72, 1)
SetObjectPosition(player, 0, 200, 0)

zerovec = CreateVector3()
Create3DPhysicsCharacterController(player, 1, zerovec, zerovec, 0.5)

ground = CreateObjectPlane(400, 400)
SetObjectRotation(ground, 90, 0, 0)
Create3DPhysicsStaticPlane(0, 1, 0, 0)

SetCameraPosition(1, 0, 200, -400)
FixCameraToObject(1, player)

movespeed = 40

do
	if GetRawKeyPressed(27) then end
	
	posx# = GetObjectWorldX(player)
	posz# = GetObjectWorldZ(player)
	
	Print(posx#)
	Print(posz#)
	
	if GetButtonPressed(1)
		Jump3DPhysicsCharacterController(player)
	endif
	
	Move3DPhysicsCharacterController(player, posx# + GetJoystickX(), posz# + GetJoystickY(), movespeed)
	Step3DPhysicsWorld()
	Sync()
loop


Is there anything I'm doing wrong here?
Posted: 25th May 2023 2:20
you're constantly telling it to move (at posx/z + joyx/z values).

the command isn't like SetObjectPosition() where you would need to account for it's current position plus any offset, it's a (relative) Move, so, just:
+ Code Snippet
Move3DPhysicsCharacterController(player, GetJoystickX(), GetJoystickY(), movespeed)

meanwhile, the Physics Demos attached HERE should shed more light.