Strange movement

If you look closely at the player character in my project, you’ll see he’s moving at a slight angle, and I’m not sure why. I need him to move exactly on the x-axis, but I’m not sure what to change in the script to fix it.

Here’s the portion of the script that controls actual movement:

Movementone.prototype.update = function(dt) {
    var forceX = 0;
    var forceZ = 0;

    // calculate force based on pressed keys
    if ( {
        forceX = -this.speed;

    if ( {
        forceX += this.speed;

    this.force.x = forceX;
    this.force.z = forceZ;

    // if we have some non-zero force
    if (this.force.length()) {

        // calculate force vector
        var rX = Math.cos(-Math.PI * 0.25);
        var rY = Math.sin(-Math.PI * 0.25);
        this.force.set(this.force.x * rX - this.force.z * rY, 0, this.force.z * rX + this.force.x * rY);

        // clamp force to the speed
        if (this.force.length() > this.speed) {

    // apply impulse to move the entity

Here’s the project:

Hi @butternyke! The only thing I noticed, is that it looks like your player’s collider isn’t exactly round. That could have to do with the above script, but I can’t help you further with that. If that’s not the problem, can you give some more information about where, when and what?

1 Like