/// <summary>
        /// Stops the character controller.
        /// </summary>
        /// <param name="time"></param>
        protected override void OnStop(GameTime time)
        {
            base.OnStop(time);

            if (this.Node.Scene.PhysicsEnabled)
            {
                this.Node.Scene.World.RemoveCollisionObject(this.ghostObject);
                this.Node.Scene.World.RemoveAction(this.kcc);

                if (this.kcc != null)
                {
                    this.kcc.Dispose();
                }
                if (this.ghostObject != null)
                {
                    this.ghostObject.Dispose();
                }
                if (this.shape != null)
                {
                    this.shape.Dispose();
                }

                this.kcc         = null;
                this.ghostObject = null;
                this.shape       = null;
            }
        }
예제 #2
0
        public virtual void LoadPlayerController(Entity playerEntity, SceneNode characterNode, object userData, Vector3 mobNodePositionUpdate)
        {
            //if (!initialized)
            //{
            //    characterToLoad = characterNode;
            //    characterEntityToLoad = playerEntity;
            //    JumpHandlerToLoad = jumpHandler;
            //    MobNodePositionUpdateToLoad = mobNodePositionUpdate;
            //    userDataToLoad = userData;
            //    return;
            //}
            if (playerController != null)
            {
                return;
            }
            float modelHeight = 2f;// (playerEntity.BoundingBox.Max.Y) / scaleFactor; // AJ: used to subtract minimum from maximum- playerEntity.BoundingBox.Minimum.y

            System.Console.WriteLine("Player capsule info: modelheight '{0}', boundingbox max '{1}', bounding box min '{2}' and playerPosition '{3}'",
                                     modelHeight, playerEntity.BoundingBox.Max.Y, playerEntity.BoundingBox.Min.Y, characterNode.Position);
            float radius = 1.75f;
            float height = 1.75f;



            ConvexShape capsule = new CapsuleShape(radius, height);

            //ConvexShape capsule = new SphereShape(radius);
            ghostObject = new PairCachingGhostObject();
            Vector3 position = new Vector3(0, 0, 0);//new Vector3(characterNode.Position.X / scaleFactor, (characterNode.Position.Y + 1500) / scaleFactor, characterNode.Position.Z / scaleFactor);
            //IndexedMatrix worldTransform = IndexedMatrix.CreateTranslation(characterNode.Position.X / scaleFactor,
            //    (characterNode.Position.Y + 1500) / scaleFactor, characterNode.Position.Z / scaleFactor);

            IndexedMatrix worldTransform = IndexedMatrix.CreateTranslation(position);

            ghostObject.SetWorldTransform(worldTransform);
            //broadphase.OverlappingPairCache.SetInternalGhostPairCallback(new GhostPairCallback());


            ghostObject.SetCollisionShape(capsule);
            ghostObject.SetCollisionFlags(CollisionFlags.CF_CHARACTER_OBJECT);
            float stepHeight = 0.35f;

            playerController = new KinematicCharacterController(ghostObject, capsule, stepHeight, 1);
            //characterToLoad = null;
            BulletMobState mobMovementState = new BulletMobState(playerController, mobNodePositionUpdate);

            //mobMovementState.JumpEvent += jumpHandler;
            mobControllers.Add(characterNode, mobMovementState);
            //m_dynamicsWorld.AddCollisionObject(ghostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
            m_dynamicsWorld.AddCollisionObject(ghostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
            //m_dynamicsWorld.AddCollisionObject(ghostObject, CollisionFilterGroups.DefaultFilter, CollisionFilterGroups.AllFilter);
            m_dynamicsWorld.AddAction(playerController);
            //collisionShapes.Add(capsule);
            //frozenTime = 0;
        }
예제 #3
0
        public override void Start()
        {
            Context.Input.SetMouseVisible(true);

            // Viewport
            _scene = new Scene(Context);
            _scene.LoadFile("Scenes/SampleScene.xml");
            _scene.CreateComponent <PhysicsWorld>();

            var character = _scene.GetChild("character");

            _body = character.CreateComponent <RigidBody>();
            _body.CollisionLayer = 1u;
            _body.SetKinematic(true);
            _body.SetTrigger(true);
            _body.SetAngularFactor(Vector3.Zero);
            _body.CollisionEventMode = CollisionEventMode.CollisionAlways;

            _shape = character.CreateComponent <CollisionShape>();
            _shape.SetCapsule(0.7f, 1.8f, new Vector3(0.0f, 0.9f, 0.0f));

            _characterController = character.CreateComponent <KinematicCharacterController>();

            _camera          = _scene.GetChild("Main Camera", true);
            _viewport        = new Viewport(Context);
            _viewport.Scene  = _scene;
            _viewport.Camera = _camera.GetComponent <Camera>();
            //var renderPath = _viewport.RenderPath;
            //renderPath.Append(Context.Cache.GetResource<XMLFile>("PostProcess/GammaCorrection.xml"));
            Context.Renderer.SetViewport(0, _viewport);
            _camera.Parent.CreateComponent <RotateObject>();

            SubscribeToEvent(E.Update, args =>
            {
                var timestep = args[E.Update.TimeStep].Float;
                Debug.Assert(this != null);

                if (ImGui.Begin("Urho3D.NET"))
                {
                    ImGui.TextColored(Color.Red, $"Ftm by luyssport\nLicense: CC Attribution - NonCommercial - ShareAlike\nhttps://sketchfab.com/3d-models/ftm-0970f30574d047b1976ba0aa6f2ef855\nFrame time: {timestep}");
                    if (ImGui.Button("Exit"))
                    {
                        Context.Engine.Exit();
                    }
                }
                ImGui.End();

                if (Context.Input.GetKeyDown(Key.KeyEscape))
                {
                    Context.Engine.Exit();
                }
            });
        }
예제 #4
0
        protected override void OnInitializePhysics()
        {
            // collision configuration contains default setup for memory, collision setup
            CollisionConf = new DefaultCollisionConfiguration();
            Dispatcher    = new CollisionDispatcher(CollisionConf);

            Broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));
            Solver     = new SequentialImpulseConstraintSolver();

            World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf);
            World.DispatchInfo.AllowedCcdPenetration = 0.0001f;
            //World.Gravity = Freelook.Up * -10.0f;

            Matrix startTransform = Matrix.Translation(10.210098f, -1.6433364f, 16.453260f);

            ghostObject = new PairCachingGhostObject();
            ghostObject.WorldTransform = startTransform;
            Broadphase.OverlappingPairCache.SetInternalGhostPairCallback(new GhostPairCallback());

            const float characterHeight = 1.75f;
            const float characterWidth  = 1.75f;
            ConvexShape capsule         = new CapsuleShape(characterWidth, characterHeight);

            ghostObject.CollisionShape = capsule;
            ghostObject.CollisionFlags = CollisionFlags.CharacterObject;

            const float stepHeight = 0.35f;

            character = new KinematicCharacterController(ghostObject, capsule, stepHeight);

            BspLoader bspLoader = new BspLoader();

            //string filename = UnityEngine.Application.dataPath + "/BulletUnity/Examples/Scripts/BulletSharpDemos/CharacterDemo/data/BspDemo.bsp";
            UnityEngine.TextAsset bytes      = (UnityEngine.TextAsset)UnityEngine.Resources.Load("BspDemo");
            System.IO.Stream      byteStream = new System.IO.MemoryStream(bytes.bytes);
            bspLoader.LoadBspFile(byteStream);
            BspConverter bsp2Bullet = new BspToBulletConverter(this);

            bsp2Bullet.ConvertBsp(bspLoader, 0.1f);

            World.AddCollisionObject(ghostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);

            World.AddAction(character);

            Vector3 v1 = new Vector3(0f, 0f, 0f);
            Vector3 v2 = new Vector3(0f, 0f, 0f);

            convexResultCallback = new ClosestConvexResultCallback(ref v1, ref v2);
            convexResultCallback.CollisionFilterMask = (short)CollisionFilterGroups.StaticFilter;
            cameraSphere = new SphereShape(0.2f);
        }
        protected override void OnInitializePhysics()
        {
            // collision configuration contains default setup for memory, collision setup
            CollisionConf = new DefaultCollisionConfiguration();
            Dispatcher    = new CollisionDispatcher(CollisionConf);

            Broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));
            Solver     = new SequentialImpulseConstraintSolver();

            World = new DiscreteDynamicsWorld(Dispatcher, Broadphase, Solver, CollisionConf);
            World.DispatchInfo.AllowedCcdPenetration = 0.0001f;
            //World.Gravity = Freelook.Up * -10.0f;

            Matrix startTransform = Matrix.Translation(10.210098f, -1.6433364f, 16.453260f);

            ghostObject = new PairCachingGhostObject();
            ghostObject.WorldTransform = startTransform;
            Broadphase.OverlappingPairCache.SetInternalGhostPairCallback(new GhostPairCallback());

            const float characterHeight = 1.75f;
            const float characterWidth  = 1.75f;
            ConvexShape capsule         = new CapsuleShape(characterWidth, characterHeight);

            ghostObject.CollisionShape = capsule;
            ghostObject.CollisionFlags = CollisionFlags.CharacterObject;

            const float stepHeight = 0.35f;

            character = new KinematicCharacterController(ghostObject, capsule, stepHeight);

            BspLoader bspLoader = new BspLoader();

            bspLoader.LoadBspFile("data/BspDemo.bsp");
            BspConverter bsp2Bullet = new BspToBulletConverter(this);

            bsp2Bullet.ConvertBsp(bspLoader, 0.1f);

            World.AddCollisionObject(ghostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);

            World.AddAction(character);

            Vector3 zero = Vector3.Zero;

            convexResultCallback = new ClosestConvexResultCallback(ref zero, ref zero);
            convexResultCallback.CollisionFilterMask = (short)CollisionFilterGroups.StaticFilter;
            cameraSphere = new SphereShape(0.2f);
        }
예제 #6
0
        public PhysicsCharacter(PhysicsWorld physics_world, Vector3 start_position, float size)
        {
            //AxisSweep3 Broadphase = new AxisSweep3(new Vector3(-1000, -1000, -1000), new Vector3(1000, 1000, 1000));

            _size = size;

            Matrix start_transformation = Matrix.Translation(start_position);

            ghostObject = new PairCachingGhostObject();
            ghostObject.WorldTransform = start_transformation;
            //ghostObject.DeactivationTime = 0.001f;

            // For character collisions
            physics_world.world.Broadphase.OverlappingPairCache.SetInternalGhostPairCallback(new GhostPairCallback());

            float characterSize   = _size;
            float characterHeight = characterSize;
            float characterWidth  = characterSize;
            //_picking_distance_minimum = characterWidth * pickingDistScale;
            ConvexShape capsule = new CapsuleShape(characterWidth, characterHeight);

            //capsule.CalculateLocalInertia(1.0f);


            capsule.Margin = 0.1f;

            //capsule.Margin = characterHeight;
            ghostObject.CollisionShape = capsule;
            ghostObject.CollisionFlags = CollisionFlags.CharacterObject;
            ghostObject.UserObject     = "me";


            float stepHeight = characterHeight / 2.0f;

            character = new KinematicCharacterController(ghostObject, capsule, stepHeight);
            character.SetJumpSpeed(characterHeight * 8.0f);
            //character.SetMaxJumpHeight(characterHeight * 1.0f);
            //character.SetFallSpeed(-physics_world.world.Gravity.Y * 1.0f);
            character.Gravity  = -physics_world.world.Gravity.Y * 1.0f;
            character.MaxSlope = OpenTK.MathHelper.DegreesToRadians(50.0f);
            character.SetUseGhostSweepTest(true);


            physics_world.world.AddCollisionObject(ghostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
            physics_world.collision_shapes.Add(capsule);
            physics_world.world.AddAction(character);
        }
예제 #7
0
        private void CreatePlayerBox()
        {
            const float  stepHeight = 0.35f;
            CapsuleShape shape      = new CapsuleShape(0.4f, charHeighth);

            _ghostObject = new PairCachingGhostObject()
            {
                CollisionShape = shape,
                CollisionFlags = CollisionFlags.CharacterObject,
                WorldTransform = Matrix.Translation(Node.GetTransform.Position.Convert() + Vector3.UnitY),
                Friction       = 0.7f
            };
            //world.AddCollisionObject(_ghostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
            world.AddCollisionObject(_ghostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
            _charController = new KinematicCharacterController(_ghostObject, shape, stepHeight);
            world.AddAction(_charController);
        }
예제 #8
0
        public void Setup(Vector3d Pos)
        {
            const float characterHeight = 1.75f;
            const float characterWidth  = 1.75f;
            var         capsule         = new CapsuleShape(characterWidth, characterHeight);

            ghostObject = new PairCachingGhostObject()
            {
                CollisionShape = capsule,
                CollisionFlags = CollisionFlags.CharacterObject,
                WorldTransform = Matrix4d.CreateTranslation(Pos)
            };
            const float stepHeight = 0.35f;

            character = new KinematicCharacterController(ghostObject, capsule, stepHeight);
            MPhysics.Instance.World.AddAction(character);
            MPhysics.Instance.World.AddCollisionObject(ghostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
        }
예제 #9
0
        protected override void OnInit()
        {
            base.OnInit();
            EyeHeight = 1.65f;
            var shape = new CapsuleShape(0.6f, 1.8f);

            CharacterGhost = new PairCachingGhostObject();
            CharacterGhost.WorldTransform = Transform.GetMatrixInverse();
            CharacterGhost.CollisionShape = shape;
            CharacterGhost.CollisionFlags = CollisionFlags.CharacterObject;
            CharacterGhost.UserObject     = GameObject;
            Controller = new KinematicCharacterController(CharacterGhost, shape, 0.1f);
            SetMaxJumpHeight(1.0f);
            SetJumpSpeed(15.0f);
            Controller.SetFallSpeed(850.0f);
            App.PhysicsWorld.AddCollisionObject(CharacterGhost, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
            App.PhysicsWorld.AddAction(Controller);
            App.PhysicsWorld.Broadphase.OverlappingPairCache.SetInternalGhostPairCallback(new GhostPairCallback());
        }
예제 #10
0
        private void CreateCharacter()
        {
            Broadphase.OverlappingPairCache.SetInternalGhostPairCallback(new GhostPairCallback());

            const float characterHeight = 1.75f;
            const float characterWidth  = 1.75f;
            var         capsule         = new CapsuleShape(characterWidth, characterHeight);

            GhostObject = new PairCachingGhostObject()
            {
                CollisionShape = capsule,
                CollisionFlags = CollisionFlags.CharacterObject,
                WorldTransform = Matrix.Translation(10.210098f, -1.6433364f, 16.453260f)
            };
            World.AddCollisionObject(GhostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);

            const float stepHeight = 0.35f;

            Character = new KinematicCharacterController(GhostObject, capsule, stepHeight);
            World.AddAction(Character);
        }
예제 #11
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        public CharacterControllerObject(IServiceLocator services)
        {
            Name = "CharacterController";

            _inputService  = services.GetInstance <IInputService>();
            _debugRenderer = services.GetInstance <DebugRenderer>();
            _simulation    = services.GetInstance <Simulation>();

            // Create character controller.
#if USE_DYNAMIC_CHARACTER_CONTROLLER
            CharacterController = new DynamicCharacterController(_simulation);
#else
            CharacterController = new KinematicCharacterController(_simulation);
#endif
            CharacterController.Enabled  = false;
            CharacterController.Position = new Vector3F(0, 0, 10);
            CharacterController.Gravity  = 10; // Setting gravity to 0 switches to fly mode (instead of walking).

            // Special: No gravity and damping for character controller.
            // The character controller uses a rigid body. The gravity and damping force effects
            // should not influence this body. The character controller handles gravity itself.
            // Gravity and Damping are ForceEffects. Each force effect has an AreaOfEffect which,
            // by default, is a GlobalAreaOfEffect (= affects all bodies in the simulation). We can
            // set a predicate method that excludes the rigid body of the character controller.
            GlobalAreaOfEffect areaOfEffect = new GlobalAreaOfEffect
            {
                Exclude = body => body == CharacterController.Body,
            };
            _simulation.ForceEffects.OfType <Gravity>().First().AreaOfEffect = areaOfEffect;
            _simulation.ForceEffects.OfType <Damping>().First().AreaOfEffect = areaOfEffect;

            // Special: Collision filtering.
            // We will have some collision objects that should not collide with the character controller.
            // We will use collision group 3 for the character and 4 for objects that should not collide
            // with it.
            CharacterController.CollisionGroup = 3;
            ICollisionFilter filter = (ICollisionFilter)_simulation.CollisionDomain.CollisionDetection.CollisionFilter;
            filter.Set(3, 4, false); // Disable collisions between group 3 and 4.
        }
        /// <summary>
        /// Starts the character controller.
        /// </summary>
        /// <param name="time"></param>
        protected override void OnStart(GameTime time)
        {
            base.OnStart(time);
            if (this.Node.Scene.PhysicsEnabled)
            {
                this.shape = new CapsuleShape(characterWidth, characterHeight);

                this.ghostObject = new PairCachingGhostObject();
                this.ghostObject.WorldTransform = this.Node.Transform.WorldTransform.ToBullet();
                this.ghostObject.CollisionShape = this.shape;
                this.ghostObject.CollisionFlags = CollisionFlags.CharacterObject;

                this.kcc = new KinematicCharacterController(this.ghostObject, this.shape, stepHeight);
                this.kcc.SetUpAxis(1);

                this.Node.Scene.World.AddCollisionObject(
                    this.ghostObject,
                    CollisionFilterGroups.CharacterFilter,
                    CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
                this.Node.Scene.World.AddAction(this.kcc);
            }
        }
예제 #13
0
        //public event JumpEventHandler JumpEvent;

        public BulletMobState(KinematicCharacterController mobController, Vector3 mobNodePositionUpdate)
        {
            this.mobController         = mobController;
            this.mobNodePositionUpdate = mobNodePositionUpdate;
        }
예제 #14
0
        public override void InitializeDemo()
        {
            base.InitializeDemo();
            SetCameraDistance(50f);

            //string filename = @"E:\users\man\bullet\xna-basic-output-1.txt";
            //FileStream filestream = File.Open(filename, FileMode.Create, FileAccess.Write, FileShare.Read);
            //BulletGlobals.g_streamWriter = new StreamWriter(filestream);

            ///collision configuration contains default setup for memory, collision setup
            m_collisionConfiguration = new DefaultCollisionConfiguration();

            ///use the default collision dispatcher. For parallel processing you can use a diffent dispatcher (see Extras/BulletMultiThreaded)
            m_dispatcher = new CollisionDispatcher(m_collisionConfiguration);

            IndexedVector3 worldMin = new IndexedVector3(-1000, -1000, -1000);
            IndexedVector3 worldMax = -worldMin;

            m_broadphase = new AxisSweep3Internal(ref worldMin, ref worldMax, 0xfffe, 0xffff, 16384, null, false);
            //pairCache = new SortedOverlappingPairCache();

            //m_broadphase = new SimpleBroadphase(1000, pairCache);

            ///the default constraint solver. For parallel processing you can use a different solver (see Extras/BulletMultiThreaded)
            SequentialImpulseConstraintSolver sol = new SequentialImpulseConstraintSolver();

            m_constraintSolver = sol;

            m_dynamicsWorld = new DiscreteDynamicsWorld(m_dispatcher, m_broadphase, m_constraintSolver, m_collisionConfiguration);
            m_dynamicsWorld.GetDispatchInfo().SetAllowedCcdPenetration(0.0001f);

            IndexedVector3 gravity = new IndexedVector3(0, -10, 0);

            m_dynamicsWorld.SetGravity(ref gravity);

            ///create a few basic rigid bodies
            IndexedVector3 halfExtents = new IndexedVector3(50, 50, 50);
            //IndexedVector3 halfExtents = new IndexedVector3(10, 10, 10);
            CollisionShape groundShape = new BoxShape(ref halfExtents);

            //CollisionShape groundShape = new StaticPlaneShape(new IndexedVector3(0,1,0), 50);

            m_collisionShapes.Add(groundShape);

            IndexedMatrix groundTransform = IndexedMatrix.CreateTranslation(new IndexedVector3(0, -50, 0));
            //IndexedMatrix groundTransform = IndexedMatrix.CreateTranslation(new IndexedVector3(0,-10,0));
            float mass = 0f;

            LocalCreateRigidBody(mass, ref groundTransform, groundShape);



            #region CharacterController
            IndexedMatrix startTransform = IndexedMatrix.Identity;
            //startTransform.setOrigin (btVector3(0.0, 4.0, 0.0));
            startTransform._origin = new IndexedVector3(10.210098f, -1.6433364f, 16.453260f);

            m_ghostObject = new PairCachingGhostObject();
            m_ghostObject.SetWorldTransform(startTransform);
            m_broadphase.GetOverlappingPairCache().SetInternalGhostPairCallback(new GhostPairCallback());
            float       characterHeight = 1.75f;
            float       characterWidth  = 1.75f;
            ConvexShape capsule         = new CapsuleShape(characterWidth, characterHeight);
            m_ghostObject.SetCollisionShape(capsule);
            m_ghostObject.SetCollisionFlags(CollisionFlags.CF_CHARACTER_OBJECT);

            float stepHeight = 0.35f;
            int   upAxis     = 1;
            m_character = new KinematicCharacterController(m_ghostObject, capsule, stepHeight, upAxis);

            m_dynamicsWorld.AddCollisionObject(m_ghostObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
            m_dynamicsWorld.AddAction(m_character);

            #endregion
        }
 private void Awake()
 {
     _controller = GetComponent <KinematicCharacterController>();
 }
예제 #16
0
        internal override bool _BuildCollisionObject()
        {
            BPhysicsWorld world = BPhysicsWorld.Get();

            if (m_collisionObject != null)
            {
                if (isInWorld && world != null)
                {
                    isInWorld = false;
                    world.RemoveCollisionObject(this);
                }
            }

            if (transform.localScale != UnityEngine.Vector3.one)
            {
                Debug.LogError("The local scale on this collision shape is not one. Bullet physics does not support scaling on a rigid body world transform. Instead alter the dimensions of the CollisionShape.");
            }

            m_collisionShape = GetComponent <BCollisionShape>();
            if (m_collisionShape == null)
            {
                Debug.LogError("There was no collision shape component attached to this BRigidBody. " + name);
                return(false);
            }
            if (!(m_collisionShape.GetCollisionShape() is ConvexShape))
            {
                Debug.LogError("The CollisionShape on this BCharacterController was not a convex shape. " + name);
                return(false);
            }

            m_collisionShape.GetCollisionShape();
            if (m_collisionObject == null)
            {
                m_collisionObject = new PairCachingGhostObject();
                m_collisionObject.CollisionShape = m_collisionShape.GetCollisionShape();
                m_collisionObject.CollisionFlags = m_collisionFlags;
                m_characterController            = new KinematicCharacterController((PairCachingGhostObject)m_collisionObject, (ConvexShape)m_collisionShape.GetCollisionShape(), stepHeight, upAxis);
                BulletSharp.Math.Matrix     worldTrans;
                BulletSharp.Math.Quaternion q = transform.rotation.ToBullet();
                BulletSharp.Math.Matrix.RotationQuaternion(ref q, out worldTrans);
                worldTrans.Origin = transform.position.ToBullet();
                m_collisionObject.WorldTransform = worldTrans;
                m_collisionObject.UserObject     = this;
                //world.world.AddCollisionObject(m_collisionObject, CollisionFilterGroups.CharacterFilter, CollisionFilterGroups.StaticFilter | CollisionFilterGroups.DefaultFilter);
                //((DynamicsWorld)world.world).AddAction(m_characterController);
            }
            else
            {
                m_collisionObject.CollisionShape = m_collisionShape.GetCollisionShape();
                m_collisionObject.CollisionFlags = m_collisionFlags;
                if (m_characterController != null)
                {
                    world.RemoveAction(m_characterController);
                }
                m_characterController = new KinematicCharacterController((PairCachingGhostObject)m_collisionObject, (ConvexShape)m_collisionShape.GetCollisionShape(), stepHeight, upAxis);
                BulletSharp.Math.Matrix     worldTrans;
                BulletSharp.Math.Quaternion q = transform.rotation.ToBullet();
                BulletSharp.Math.Matrix.RotationQuaternion(ref q, out worldTrans);
                worldTrans.Origin = transform.position.ToBullet();
                m_collisionObject.WorldTransform = worldTrans;
                m_collisionObject.UserObject     = this;
            }
            return(true);
        }