Neos-Metaverse / NeosPublic

A public issue/wiki only repository for the NeosVR project
196 stars 9 forks source link

CharacterController should respect player's current height #585

Closed candypheonixIO closed 3 years ago

candypheonixIO commented 4 years ago

Small feature request

So, most VR titles don't have this for some reason, but I would really love to see the character controller respect player height, especially when using a room-scale playspace, physical mode, and not using seated mode.

This would be very useful for times when a player is in a taller avatar, or a world requires a player to crouch.

LacyDoes commented 4 years ago

Height as in the user's head position? Essentially scaling the capsule collider on the Y axis based on where the user's head is on the Y relative to the user's root.

candypheonixIO commented 4 years ago

Correct

Frooxius commented 4 years ago

Unfortunately this is actually pretty complicated. Changing the height of the character controller dynamically is very inefficient operation with the current physics library, which is why it's not done at the moment.

We plan on upgrading to BEPU v2, which should be more efficient in this regard. Even if it's not I want to look to some good compromise there, but it'll have to wait until then.

candypheonixIO commented 4 years ago

I'm sure if the character controller for the physics library has a basic api for controlling character controller height, width, center, etc... you could just do this:

// Get head height in local space
        float headHeight = Mathf.Clamp(Player.instance.hmdTransform.localPosition.y, 0.5f, 2.0f);
        characterController.height = headHeight;

Of course, if you aren't using SteamVR's SDK for input, you can just use the equivalent to Player.Instance.hmdTransform

candypheonixIO commented 4 years ago

that snippet can go inside of the fixedUpdate that holds the centering code for keeping the character controller collider with the player's head.

Frooxius commented 4 years ago

Unfortunately that's not applicable. That's code for Unity and its physics engine, which we aren't using. At the moment we're using BEPU physics v1. Generally Neos is its own game engine for the most part, so Unity code can't be used at all.

Like I said, changing the height dynamically is a lot more complicated. I've already investigated the issue. It can technically be done with current version of BEPU, but the way the character controller is setup in the physics engine that's pretty expensive operation, it's designed to stay mostly the same height.

I think this was redesigned with BEPU v2 so upgrade alone can help. But until we upgrade to that I don't plan on working on this, so it will have to wait, sorry.

Frooxius commented 3 years ago

This has now been implemented in 2021.8.25.1127 with BEPUv2 upgrade!