Character movement (417691)

I’d like to know how come when my player slides left and right I get a jerky motion..not as smooth as I would going straight.

Thanks in advance.
XC

You’ll probably have to provide some more information. Are you using the ‘first-person controller’ prefab? Or something else?

Meanwhile, here’s one suggestion: check your input setup and make sure the ‘lateral’ axis is set up the same way as the ‘forward/backward’ axis (other than name and keys, of course).

Yes I am using the ‘first-person controller’ prefab. I’m sorry but I cn’t locate ‘lateral’ axis.

Thanks,
XC

‘lateral’ just means side-to-side. I think the name of the axis that the FPSWalker script uses by default for this is named ‘Horizontal’.

(Note that I’m not saying for sure that this is what’s causing your problem, but it’s probably at least worth checking to make sure the horizontal axis is set up for smooth motion.)

I looked through the FPSWalker script


var speed = 6.0;
var jumpSpeed = 8.0;
var gravity = 20.0;

private var moveDirection = Vector3.zero;
private var grounded : boolean = false;

function FixedUpdate() {
if (grounded) {
// We are grounded, so recalculate movedirection directly from axes
moveDirection = new Vector3(Input.GetAxis(“Horizontal”), 0, Input.GetAxis(“Vertical”));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;

if (Input.GetButton (“Jump”)) {
moveDirection.y = jumpSpeed;
}
}

// Apply gravity
moveDirection.y -= gravity * Time.deltaTime;

// Move the controller
var controller : CharacterController = GetComponent(CharacterController);
var flags = controller.Move(moveDirection * Time.deltaTime);
grounded = (flags CollisionFlags.CollidedBelow) != 0;
}

@script RequireComponent(CharacterController)

what do I need to change to have the player move side to side smoothly.

I’m sorry for not getting it. I’m still new to scripting.

Thanks,
XC

What I’m suggesting is that you look at your input setup (Edit->Project Settings->Input), and make sure that the axis named ‘Horizontal’ is set up the same way as the axis named ‘Vertical’. The keys will be different of course, but you want the other settings to be the same.

Again, I have no idea if this is what’s causing your problem - I’m just making a guess as to why lateral movement would seem less ‘smooth’ than forward/backward movement.

If that doesn’t solve the problem, perhaps you could clarify what you mean by ‘jerky’. Do you mean the player starts and stops abruptly when moving laterally, but has a slight acceleration and deceleration when moving forward and backward? Or something else?

Hi Jesse,

Thank you for pointing me in the right direction to change the setting to my liking. I changed the value in Axes/Mouse X/Sensitivity. It works great.

Thank you for your patience.