INNER CODE UNIT · Rust

along

dust-engine/dust · crates/character/src/lib.rs:273

            let along = wish - normal * normal.dot(wish);
            velocity = along.normalize_or_zero() * wish.length();
            // A slight push into the ground; move-and-slide clips it against the
            // ground plane, which keeps the capsule seated over small dips.
            velocity.y -= 1.0;
            if character.jump_requested {
                velocity.y = character.jump_speed;
            }
        } else {
            velocity.y -= character.gravity * dt;
            let horizontal = Vec3::new(velocity.x, 0.0, velocity.z);
            velocity += (wish - horizontal) * (character.air_control * dt).min(1.0);
        }
        character.jump_requested = false;

        // Main move. Note any surface too steep to stand on: that is a wall or a
        // ledge face, and the candidate for a step-up.
        let mut blocked = false;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…