Character controller on standing object - Rotation

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
needshelprendering
Posts: 25
Joined: Mon Sep 17, 2012 1:17 am

Character controller on standing object - Rotation

Post by needshelprendering »

Hi Norbo,

I am using a character controller for my game, and I was wondering, would it be possible to have the character rotate when the object below it rotates?

For example:
In your CharacterPlaygroundDemo, when I stand on the spinning blade, my character still faces the same direction while spinning.
In the tank demo, when I stand on top of the tank and turn, my character will not turn with the tank.

Thanks.

Here is a gif, I feel I am pretty bad at explaining it:
Image
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Character controller on standing object - Rotation

Post by Norbo »

This is best implemented as a camera effect. From the CharacterCameraControlScheme, modified slightly:

Code: Select all

            //Rotate the camera of the character based on the support velocity, if a support with velocity exists.
            //This can be very disorienting in some cases; that's why it is off by default!
            if (Character.SupportFinder.HasSupport)
            {
                SupportData? data;
                if (Character.SupportFinder.HasTraction)
                    data = Character.SupportFinder.TractionData;
                else
                    data = Character.SupportFinder.SupportData;
                var support = data.Value.SupportObject as EntityCollidable;
                if (support != null) // && !support.Entity.IsDynamic) //Having the view turned by dynamic entities is extremely confusing for the most part.
                {
                    float dot = Vector3.Dot(support.Entity.AngularVelocity, Character.Body.OrientationMatrix.Up);
                    Camera.Yaw(dot * dt);
                }
            }
I would recommend restricting the activation of this to entities which the player would expect their view to follow. If the player walks on top of a tiny insignificant cube and their view spins with the cube's response to the character, vomitous things tend to happen.
needshelprendering
Posts: 25
Joined: Mon Sep 17, 2012 1:17 am

Re: Character controller on standing object - Rotation

Post by needshelprendering »

I had no idea that would be in there, I should have looked first. it works perfectly. Thank you Norbo.
Post Reply