Example #1
0
        public void Move(CharacterBase gameObjectBehavior)
        {
            //Helper.Rotate(gameObjectBehavior, direction);


            if (CanMove(gameObjectBehavior))
            {
                Vector3 currentPosition = gameObjectBehavior.transform.position;
                Vector3 nextPosition    = gameObjectBehavior.transform.position + direction;

                PhysicsHelper.Rotate(gameObjectBehavior, nextPosition, Enums.TypeOfVector3.NextPosition);

                if (!PhysicsHelper.CharacterSphereCast(gameObjectBehavior))
                {
                    gameObjectBehavior.StartCoroutine(MakeMove(gameObjectBehavior, currentPosition,
                                                               nextPosition, duration));
                }
            }
        }
Example #2
0
        private void RotateAndMove(CharacterBase gameObjectBehavior)
        {
            wallPass = gameObjectBehavior.CanWallPass();

            PhysicsHelper.Rotate(gameObjectBehavior, direction, Enums.TypeOfVector3.Direction);

            if (!IsBorder(gameObjectBehavior.transform.position, direction))
            {
                if (wallPass)
                {
                    //gameObjectBehavior.transform.Translate(direction * Time.deltaTime * speed, Space.World);
                    gameObjectBehavior.transform.position += direction * Time.deltaTime * speed;
                }
                else if (!PhysicsHelper.CharacterSphereCast(gameObjectBehavior))
                {
                    //gameObjectBehavior.transform.Translate(direction * Time.deltaTime * speed, Space.World);
                    gameObjectBehavior.transform.position += direction * Time.deltaTime * speed;
                }
            }
        }