#What is a good way to slow down turns?

4 messages · Page 1 of 1 (latest)

civic urchin
#

Currently my movement allows me to change directions instantly, including 180 degree turns. In most of the games I've played this is not possible as rotating is noticeably delayed.

Is it possible to solve this problem without sacrificing precise and responsive movement?

func _allow_movement(delta: float) -> void:
    movement_direction = Vector3(input_direction.x, 0.0, input_direction.y).normalized()
    movement_direction = movement_direction.rotated(Vector3.UP, camera.rotation.y)

    if not movement_direction.is_zero_approx():
        if horizontal_velocity.length() < target_velocity:
            current_horizontal_velocity = move_toward(current_horizontal_velocity, target_velocity, (acceleration * delta))
        else:
            current_horizontal_velocity = move_toward(current_horizontal_velocity, target_velocity, (friction * delta))

        velocity.x = (movement_direction.x * current_horizontal_velocity)
        velocity.z = (movement_direction.z * current_horizontal_velocity)

        var bas: Basis = Basis.looking_at(velocity.slide(Vector3.UP).normalized())
        global_basis = global_basis.slerp(bas, (rotation_speed * delta))
    else:
        horizontal_velocity = velocity.move_toward(Vector3.ZERO, (friction * delta))

        velocity.x = horizontal_velocity.x
        velocity.z = horizontal_velocity.z
steel zealot
#

you need to study the game you want to take inspiration from. see how they deal with the character and the camera.

civic urchin
#

Well in the games that I've played, holding a direction other than forward simply accelerates in that direction. For instead, holding backward would start to accelerate backward, but this manifests as the character rapidly slowing down and only turning once they start moving in the other direction.

Risk of Rain 2 behaves this way, as an example. But I was asking if there are any other common ways to handle this problem.

steel zealot