void Update()
        {
            if (characterMovement.freeFalling)
            {
                ragdollController.GoRagdoll("free fall");
            }

            // if we're falling, dont let us go "up"
            // ragdoll was falling up stairs...
            characterMovement.preventUpwardsGroundedMotion = ragdollController.state == RagdollControllerState.Falling;

            // dont accept any movement changes from player input, or ai input
            characterMovement.disableExternalMovement = ragdollController.state != RagdollControllerState.Animated || ragdollController.isGettingUp;

            /*
             *  skip moving the main transform if we're completely ragdolled, or waiting to reorient
             *  the main transform via the ragdoll controller
             */
            characterMovement.disableAllMovement = ragdollController.state == RagdollControllerState.Ragdolled || ragdollController.state == RagdollControllerState.TeleportMasterToRagdoll;


            /*
             *  when animated or blending to animation
             *      use character controller movement
             *
             *      it has less step offset jitter than the normal transform movement
             *      especially when getting up
             *
             *  else when falling:
             *
             *      use normal transform stuff (dont want the character controller collisions messing stuff up)
             *      for falling /calculating fall ( we need all exterion collisions to reach ragdol bones)
             *      and teh characer chontroller acts as a 'protective shell' when it's enabled
             */

            characterMovement.usePhysicsForMove = ragdollController.state == RagdollControllerState.Animated || ragdollController.state == RagdollControllerState.BlendToAnimated;


            //cehck if we started getting up
            if (ragdollController.state == RagdollControllerState.BlendToAnimated)
            {
                //set zero speed
                if (characterMovement.currentSpeed != 0)
                {
                    characterMovement.SetMovementSpeed(0);
                }
            }

            int currentSpeed = (int)characterMovement.currentSpeed;

            if (currentSpeed < 0 || currentSpeed >= fallDecaySpeeds.Length)
            {
                Debug.LogError("current speed: " + currentSpeed + " :: out of range for fall decays");
            }
            else
            {
                //set the ragdolls fall speed based on our speed
                ragdollController.SetFallSpeed(fallDecaySpeeds[(int)characterMovement.currentSpeed]);
            }
        }
Exemplo n.º 2
0
        void Update()
        {
            UpdateRagdollGrabberPosition();

            CheckCameraTarget();
            UpdateSloMo();

            /* shoot from the clicked position */
            if (Input.GetMouseButtonDown(0))
            {
                if (currentAmmoType != null)
                {
                    currentAmmoType.FireAmmo(this, cam.ScreenPointToRay(Input.mousePosition), shootMask, 1);
                }
            }
            if (Input.GetMouseButtonDown(1))
            {
                StartCoroutine(CheckForRagdollGrab(cam.ScreenPointToRay(Input.mousePosition)));
            }

            /* launch the ball from the camera */
            if (Input.GetKeyDown(KeyCode.B))
            {
                GameObject.FindObjectOfType <DemoSceneController>().SwitchActiveScene();
            }
            /* drop teh ball on the controlled character */
            if (Input.GetKeyDown(KeyCode.E))
            {
                ToggleAmmoType();
            }

            if (controlledCharacter)
            {
                /* manually ragdoll the controlled character */
                if (Input.GetKeyDown(KeyCode.R))
                {
                    ragdollController.GoRagdoll("manual");
                }

                /* moved the controlled character */
                if (!controlledCharacter.disableExternalMovement)
                {
                    //do turning
                    controlledCharacter.transform.Rotate(0f, Input.GetAxis("Horizontal") * turnSpeed * Time.deltaTime, 0f);
                    //set speed
                    controlledCharacter.SetMovementSpeed(Input.GetAxis("Vertical") * (Input.GetKey(KeyCode.LeftShift) ? 2 : 1));
                }

                //disable char control
                if (Input.GetKeyDown(KeyCode.P))
                {
                    AttachToCharacter(null);
                }
            }
            else
            {
                /* look for character to control */
                if (Input.GetKeyDown(KeyCode.P))
                {
                    StartCoroutine(CheckForCharacter(cam.ScreenPointToRay(Input.mousePosition)));
                }
            }
        }
Exemplo n.º 3
0
 void Start()
 {
     //maybe run, maybe walk
     characterMovement.SetMovementSpeed(Random.value < .5f ? 1 : 2);
     destination = new Vector3(Random.Range(-playRadius, playRadius), 0, Random.Range(-playRadius, playRadius));
 }