Page 1 of 1

Character controller on standing object - Rotation

Posted: Sun Oct 06, 2013 12:19 pm
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

Re: Character controller on standing object - Rotation

Posted: Sun Oct 06, 2013 7:45 pm
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.

Re: Character controller on standing object - Rotation

Posted: Mon Oct 07, 2013 1:18 am
by needshelprendering
I had no idea that would be in there, I should have looked first. it works perfectly. Thank you Norbo.