IsInTransition() public method

public IsInTransition ( int layerIndex ) : bool
layerIndex int
return bool
コード例 #1
1
ファイル: ChangeBool.cs プロジェクト: Rulfer/Steam-Buccaneers
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        //This is where combatanimation gets turned of after played wanted amount of time.
        //Portrett is player animation
            if (animator.name == "Portrett")
            {
                if (stateInfo.normalizedTime > 1 && !animator.IsInTransition (layerIndex))
                {
                    if (animator.GetBool ("isHappyMainCharacter") == true)
                    {
                        animator.SetBool ("isHappyMainCharacter", false);//Length 2 sec
                    }

                    if (animator.GetBool ("isAngryMainCharacter") == true)
                    {
                        animator.SetBool ("isAngryMainCharacter", false);//Length 2.45 sec
                    }
                }
            }
        //This is boss animation
            else if (animator.name == "Portrett2_boss")
            {
                if (stateInfo.normalizedTime > 2 && !animator.IsInTransition (layerIndex))
                {
                    if (animator.GetBool ("isHappyBoss") == true)
                    {
                        animator.SetBool ("isHappyBoss", false);//Length 1 sec
                    }

                    if (animator.GetBool ("isAngryBoss") == true)
                    {
                        animator.SetBool ("isAngryBoss", false);//Length 1.2 sec
                    }
                }
            }
        //This is enemy animation
            else if (animator.name == "Portrett2_marine")
            {
                if (stateInfo.normalizedTime > 2 && !animator.IsInTransition (layerIndex))
                {
                    if (animator.GetBool ("isHappyMarine") == true)
                    {
                        animator.SetBool ("isHappyMarine", false);//Length 1.2 sec
                    }

                    if (animator.GetBool ("isAngryMarine") == true)
                    {
                        animator.SetBool ("isAngryMarine", false);//Length 1.2 sec
                    }
                }
            }
    }
コード例 #2
0
ファイル: Animal.cs プロジェクト: skdeng/SpaceCadets
 //prepare the animal to start walking animation
 //param: anim   - animator of the animal
 protected void startWalking(Animator anim) {
     if (anim.IsInTransition(0) && bStartMoving) {
         bMoving = true;
         bStartMoving = false;
         transform.rotation = Quaternion.LookRotation(moveVector) * transform.rotation;
     }
 }
コード例 #3
0
 protected override bool ConditionToChangeOn(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (animator.GetBool(GroundVariableName) && !animator.IsInTransition(layerIndex)) {
         return ChangeOnGround;
     } else {
         return ChangeOnAir;
     }
 }
コード例 #4
0
ファイル: PlayerRunning.cs プロジェクト: Lobo-Prix/TeraTale
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (animator.IsInTransition(0))
         return;
     _player.FacingDirectionUpdate();
     if (_player.isArrived)
         _animator.SetBool("Run", false);
 }
コード例 #5
0
    private IEnumerator WaitForAnimation(Animator animator)
    {
        do
        {
            yield return null;
        } while (animator.GetCurrentAnimatorStateInfo(0).IsName("Armature|Victory") || animator.GetCurrentAnimatorStateInfo(0).IsName("Armature|Victory0") || animator.IsInTransition(0));

        laser.SetActive(true);
    }
コード例 #6
0
ファイル: EnemyChasing.cs プロジェクト: Lobo-Prix/TeraTale
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (animator.IsInTransition(0))
         return;
     _enemy.FacingDirectionUpdate();
     if (_enemy.mainTarget)
         _nma.destination = _enemy.mainTarget.transform.position;
     else
         animator.SetBool("Chase", false);
 }
コード例 #7
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (stateInfo.normalizedTime > 1 && !animator.IsInTransition(layerIndex)) {

            _counterWaitingTime += Time.deltaTime;

            if (_counterWaitingTime >= WaitingTime) {
                Application.LoadLevel(Application.loadedLevel);
            }
        }
    }
コード例 #8
0
        public sealed override void OnStateUpdate(UnityEngine.Animator animator, AnimatorStateInfo stateInfo, int layerIndex, AnimatorControllerPlayable controller)
        {
            if (!animator.gameObject.activeSelf)
            {
                return;
            }

            if (animator.IsInTransition(layerIndex) && animator.GetNextAnimatorStateInfo(layerIndex).fullPathHash == stateInfo.fullPathHash)
            {
                OnSLTransitionToStateUpdate(animator, stateInfo, layerIndex);
                OnSLTransitionToStateUpdate(animator, stateInfo, layerIndex, controller);
            }

            if (!animator.IsInTransition(layerIndex) && m_FirstFrameHappened)
            {
                OnSLStateNoTransitionUpdate(animator, stateInfo, layerIndex);
                OnSLStateNoTransitionUpdate(animator, stateInfo, layerIndex, controller);
            }

            if (animator.IsInTransition(layerIndex) && !m_LastFrameHappened && m_FirstFrameHappened)
            {
                m_LastFrameHappened = true;

                OnSLStatePreExit(animator, stateInfo, layerIndex);
                OnSLStatePreExit(animator, stateInfo, layerIndex, controller);
            }

            if (!animator.IsInTransition(layerIndex) && !m_FirstFrameHappened)
            {
                m_FirstFrameHappened = true;

                OnSLStatePostEnter(animator, stateInfo, layerIndex);
                OnSLStatePostEnter(animator, stateInfo, layerIndex, controller);
            }

            if (animator.IsInTransition(layerIndex) && animator.GetCurrentAnimatorStateInfo(layerIndex).fullPathHash == stateInfo.fullPathHash)
            {
                OnSLTransitionFromStateUpdate(animator, stateInfo, layerIndex);
                OnSLTransitionFromStateUpdate(animator, stateInfo, layerIndex, controller);
            }
        }
コード例 #9
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
 //
 //}
 // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (stateInfo.normalizedTime > WhenDestroy && !animator.IsInTransition(layerIndex)) {
         if (DependsOnSpeed) {
             if (animator.GetFloat(SpeedVariableName) == Speed) {
                 Destroy(animator.gameObject);
             }
         } else {
             Destroy(animator.gameObject);
         }
     }
 }
コード例 #10
0
	IEnumerator DisablePanelDeleyed (Animator anim)
	{
		bool closedStateReached = false;
		bool wantToClose = true;
		while (!closedStateReached && wantToClose) {
			if (!anim.IsInTransition (0))
				closedStateReached = anim.GetCurrentAnimatorStateInfo (0).IsName ("Closed");
			
			wantToClose = !anim.GetBool (m_OpenParameterId);
			
			yield return new WaitForEndOfFrame ();
		}
		
		if (wantToClose)
			anim.gameObject.SetActive (false);
	}
コード例 #11
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (stateInfo.normalizedTime > WhenApplyDelay && !animator.IsInTransition(layerIndex)) {

            if (_counterTimeTillResume >= TimeTillResume) {
                _actualSpeed += SpeedAugmentedFactor;
            } else {
                _counterTimeTillResume += Time.deltaTime;

                _actualSpeed -= SpeedDecreaseFactor;
            }

            _actualSpeed = Mathf.Clamp(_actualSpeed, DelaySpeedValue, ResumeSpeedValue);
            animator.SetFloat(SpeedVariableName, _actualSpeed);
        }
    }
コード例 #12
0
ファイル: StopBool.cs プロジェクト: coderDarren/GGJ2016
	// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
        frameCount++;
        Debug.Log(frameCount);
        if (stateInfo.normalizedTime > 1 && !animator.IsInTransition(0))
        {
            switch (boolToStop)
            {
                case BooltoStop.Dive: PlayerData.Instance.canDive = false; break;
                case BooltoStop.Ninja: PlayerData.Instance.canNinja = false; break;
                case BooltoStop.Punch: PlayerData.Instance.canPunch = false; break;
            }
        }
        if (frameCount >= 30 && !shot && projectile != null)
        {
            GameObject go = Instantiate(projectile) as GameObject;
            go.transform.rotation = animator.transform.rotation;
            go.transform.position = animator.transform.position + animator.transform.up * 1 + animator.transform.forward * 1;
            shot = true;
        }
    }
コード例 #13
0
ファイル: CoroutineExt.cs プロジェクト: hhuwvom/New-Coroutine
    public static IEnumerator WaitForAnimatorFinish(Animator animator, int layer)
    {
        while( true ) {
            yield return null;

            if( animator.IsInTransition(layer) )
                continue;

            AnimatorStateInfo stateInfo = animator.GetCurrentAnimatorStateInfo(layer);

            Debug.Log("state info name is attack ? " + stateInfo.IsName("Attack"));
            Debug.Log("state info name is attack done ? " + stateInfo.IsName("Attack Done"));
            Debug.Log("state info name is idle ? " + stateInfo.IsName("Idle"));

            Debug.Log("animate state info = " + stateInfo.normalizedTime);

            if( stateInfo.normalizedTime >= 1 )
                break;
        }
    }
コード例 #14
0
ファイル: UISystem.cs プロジェクト: namlunoy/ARConcertUnity
    private IEnumerator DisablePanelDeleyed(Animator anim)
    {
        bool closedStateReached = false; // Closed 상태로 완전히 전이되었는가?
        bool wantToClose = true;    // 코루틴 도중에 anim 값바뀜 체크?
        while (!closedStateReached && wantToClose)
        {
            if (!anim.IsInTransition(0))
            {
                closedStateReached = anim.GetCurrentAnimatorStateInfo(0).IsName(_closedStateName);
            }

            wantToClose = !anim.GetBool(_openParameterId);

            yield return new WaitForEndOfFrame();
        }

        if (wantToClose)
        {
            anim.gameObject.SetActive(false);
        }
    }
コード例 #15
0
ファイル: FiniteBehaviour.cs プロジェクト: Tecaa/Configurerer
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {        
        if (_BehaviourState == AnimationBehaviourState.INITIAL_POSE)
        {
            if (!animator.IsInTransition(0))
                animator.speed = 0;
            return;
        }
        const float INTERVAL = 0.1f;
        if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
        {
            timeSinceCapture += Time.deltaTime;
            /*
            if (timeSinceCapture > INTERVAL)
            {
                timeSinceCapture = timeSinceCapture - INTERVAL;
                if (exerciseDataGenerator == null)
                    exerciseDataGenerator = GameObject.FindObjectOfType<Detector.ExerciseDataGenerator>();
                if (this.exerciseDataGenerator != null)
                    this.exerciseDataGenerator.CaptureData();
            }*/
        }

        DateTime temp = DateTime.Now;

        if ((_BehaviourState != AnimationBehaviourState.STOPPED && _BehaviourState != AnimationBehaviourState.RUNNING_DEFAULT)
    && (endRepTime == null || new TimeSpan(0, 0, (int)_RealParams.SecondsBetweenRepetitions) <= temp - endRepTime))
        {

            if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
            {
                OnRepetitionReallyStart();
                BeginRep = true;
            }
            if (stateInfo.normalizedTime >= 1.0f && haCambiadoDeEstado)
            {
                BeginRep = false;
                if (this._behaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
                {
                    OnLerpRoundTripEnd();
                    if (!IsInterleaved || (IsInterleaved && limb == Limb.Right))
                    {

                        if ((!this.IsWeb) && (!this.IsInInstruction) && (!this.IsInInstruction))
                        {

                            this.PauseAnimation();
                        }
                        // importante: el orden de llamadas es esencial para el correcto funcionamiento
                        OnRepetitionEnd();
                    }
                    if (IsInterleaved)
                    {
                        haCambiadoDeEstado = false;
                        animator.SetTrigger("ChangeLimb");
                    }
                    if(!IsInterleaved && (this.IsWeb || this.IsInInstruction) )
                    {
                        animator.Play(animator.GetCurrentAnimatorStateInfo(0).fullPathHash, 0, 0);
                    }
                    if (this._BehaviourState == AnimationBehaviourState.STOPPED)
                    {
                        endRepTime = null;
                    }
                }
                else if (this._behaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
                {
                    OnRepetitionEnd();
                    Stop();
                }

            }
            else
            {
                if (this._BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS || this._behaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
                {
                    if (stateInfo.normalizedTime <= 0.5f)
                    {
                        animator.speed = this._RealParams.ForwardSpeed;
                    }
                    else
                    {
                        animator.speed = this._RealParams.BackwardSpeed;
                    }
                }
            }
        }
    }
コード例 #16
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        clockBehaviour.Update();

        if (_BehaviourState == AnimationBehaviourState.INITIAL_POSE)
        {
            if (!animator.IsInTransition(0))
                animator.speed = 0;
            return;
        }

        //if (!this.IsCentralNode && this.animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1)
        //    exerciceMovement = -1;

        if (_isAnimationPreparing || _isAnimationStopped)
            return;

    }
コード例 #17
0
 protected override bool ConditionToChangeOn(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     return _playerController.Life <= Life && !animator.IsInTransition(layerIndex);
 }
コード例 #18
0
ファイル: BotControlScript.cs プロジェクト: Jeace/ADGLADIUM
    private AnimatorStateInfo layer2CurrentState; // a reference to the current state of the animator, used for layer 2

    #endregion Fields

    #region Methods

    void FixedUpdate()
    {
        anim = GetComponent<Animator>();
        float h = Input.GetAxis("Horizontal");				// setup h variable as our horizontal input axis
        float v = Input.GetAxis("Vertical");				// setup v variables as our vertical input axis
        anim.SetFloat("Speed", v);							// set our animator's float parameter 'Speed' equal to the vertical input axis
        anim.SetFloat("Direction", h); 						// set our animator's float parameter 'Direction' equal to the horizontal input axis
        anim.speed = animSpeed;								// set the speed of our animator to the public variable 'animSpeed'
        anim.SetLookAtWeight(lookWeight);					// set the Look At Weight - amount to use look at IK vs using the head's animation
        currentBaseState = anim.GetCurrentAnimatorStateInfo(0);	// set our currentState variable to the current state of the Base Layer (0) of animation

        if(anim.layerCount ==2)
            layer2CurrentState = anim.GetCurrentAnimatorStateInfo(1);	// set our layer2CurrentState variable to the current state of the second Layer (1) of animation

        // LOOK AT ENEMY

        // if we hold Alt..
        if(Input.GetButton("Fire2"))
        {
            // ...set a position to look at with the head, and use Lerp to smooth the look weight from animation to IK (see line 54)
            anim.SetLookAtPosition(enemy.position);
            lookWeight = Mathf.Lerp(lookWeight,1f,Time.deltaTime*lookSmoother);
        }
        // else, return to using animation for the head by lerping back to 0 for look at weight
        else
        {
            lookWeight = Mathf.Lerp(lookWeight,0f,Time.deltaTime*lookSmoother);
        }

        // STANDARD JUMPING

        // if we are currently in a state called Locomotion (see line 25), then allow Jump input (Space) to set the Jump bool parameter in the Animator to true
        /*if (currentBaseState.nameHash == locoState)
        {*/
            if(Input.GetButtonDown("Jump"))
            {
                anim.SetBool("Jump", true);
            }
        //}

        // if we are in the jumping state...
        else if(currentBaseState.nameHash == jumpState)
        {
            //  ..and not still in transition..
            if(!anim.IsInTransition(0))
            {
                /*if(useCurves)
                    // ..set the collider height to a float curve in the clip called ColliderHeight
                    col.height = anim.GetFloat("ColliderHeight");*/

                // reset the Jump bool so we can jump again, and so that the state does not loop
                anim.SetBool("Jump", false);
            }

            // Raycast down from the center of the character..
            Ray ray = new Ray(transform.position + Vector3.up, -Vector3.up);
            RaycastHit hitInfo = new RaycastHit();

            if (Physics.Raycast(ray, out hitInfo))
            {
                // ..if distance to the ground is more than 1.75, use Match Target
                if (hitInfo.distance > 1.75f)
                {

                    // MatchTarget allows us to take over animation and smoothly transition our character towards a location - the hit point from the ray.
                    // Here we're telling the Root of the character to only be influenced on the Y axis (MatchTargetWeightMask) and only occur between 0.35 and 0.5
                    // of the timeline of our animation clip
                    anim.MatchTarget(hitInfo.point, Quaternion.identity, AvatarTarget.Root, new MatchTargetWeightMask(new Vector3(0, 1, 0), 0), 0.35f, 0.5f);
                }
            }
        }

        // JUMP DOWN AND ROLL

        // if we are jumping down, set our Collider's Y position to the float curve from the animation clip -
        // this is a slight lowering so that the collider hits the floor as the character extends his legs
        else if (currentBaseState.nameHash == jumpDownState)
        {
            col.center = new Vector3(0, anim.GetFloat("ColliderY"), 0);
        }

        // if we are falling, set our Grounded boolean to true when our character's root
        // position is less that 0.6, this allows us to transition from fall into roll and run
        // we then set the Collider's Height equal to the float curve from the animation clip
        else if (currentBaseState.nameHash == fallState)
        {
            col.height = anim.GetFloat("ColliderHeight");
        }

        // if we are in the roll state and not in transition, set Collider Height to the float curve from the animation clip
        // this ensures we are in a short spherical capsule height during the roll, so we can smash through the lower
        // boxes, and then extends the collider as we come out of the roll
        // we also moderate the Y position of the collider using another of these curves on line 128
        else if (currentBaseState.nameHash == rollState)
        {
            if(!anim.IsInTransition(0))
            {
                if(useCurves)
                    col.height = anim.GetFloat("ColliderHeight");

                col.center = new Vector3(0, anim.GetFloat("ColliderY"), 0);

            }
        }
        // IDLE
        /*
        // check if we are at idle, if so, let us Wave!
        else if (currentBaseState.nameHash == idleState)
        {
            if(Input.GetButtonUp("Jump"))
            {
                anim.SetBool("Wave", true);
            }
        }
        // if we enter the waving state, reset the bool to let us wave again in future
        if(layer2CurrentState.nameHash == waveState)
        {
            anim.SetBool("Wave", false);
        }
        */
    }
コード例 #19
0
ファイル: PanelManager.cs プロジェクト: TakaakiJimbo/Race
    private void DisablePanelDeleyed(Animator anim)
    {
        bool closedStateReached = false;
        bool wantToClose = true;
        if (!closedStateReached && wantToClose)
        {
            if (!anim.IsInTransition(0))
                closedStateReached = anim.GetCurrentAnimatorStateInfo(0).IsName(k_ClosedStateName);

            wantToClose = !anim.GetBool(m_OpenParameterId);
        }

        if (wantToClose)
            anim.gameObject.SetActive(false);
    }
コード例 #20
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {        
        if (_BehaviourState == AnimationBehaviourState.INITIAL_POSE)
        {
            if (!animator.IsInTransition(0) && this.IsCentralNode)
            {
                animator.speed = 0;
            }
                return;
        }

        const float INTERVAL = 0.1f;
        if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
        {
            timeSinceCapture += Time.deltaTime;
            if (timeSinceCapture > INTERVAL)
            {
                timeSinceCapture = timeSinceCapture - INTERVAL;
                //if (exerciseDataGenerator == null)
                //    exerciseDataGenerator = GameObject.FindObjectOfType<ExerciseDataGenerator>();
                //TODO: rescatar de base de datos o diccionario
                //TODO: rescatar captureData
                //DebugLifeware.Log("grabando frame ", DebugLifeware.Developer.Marco_Rojas);
                //if (this.exerciseDataGenerator != null)
                //    this.exerciseDataGenerator.captureData(ActionDetector.ActionDetector.DetectionMode.BoundingBoxBased);
            }
        }

        DateTime now = DateTime.Now;
        if (this.CentralNode.endRepTime != null && _BehaviourState != AnimationBehaviourState.RUNNING_DEFAULT &&
            new TimeSpan(0, 0, (int)this.CentralNode._RealParams.SecondsBetweenRepetitions) > now - this.CentralNode.endRepTime)
        {
            animator.speed = 0;
        }

        if ((_BehaviourState != AnimationBehaviourState.STOPPED && _BehaviourState != AnimationBehaviourState.RUNNING_DEFAULT)
            && (this.CentralNode.endRepTime == null || new TimeSpan(0, 0, (int)this.CentralNode._RealParams.SecondsBetweenRepetitions) <= now - this.CentralNode.endRepTime))
        {

            if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
            {
                Debug.Log("supuesto really start" + "  "+ stateInfo.normalizedTime + " " + animator.speed);
                this.CentralNode.OnRepetitionReallyStart();
                BeginRep = true;
            }

            //Debug.Log("ha cambiado de estado " + haCambiadoDeEstado);
            
            if (stateInfo.normalizedTime < 1.0f)
            {
                if (this._BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS || this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
                {
                    if (animator.speed != this.CentralNode._RealParams.ForwardSpeed  && stateInfo.normalizedTime <= 0.5f)
                    {
                        animator.speed = this.CentralNode._RealParams.ForwardSpeed;
                    }
                    else if (animator.speed != this.CentralNode._RealParams.BackwardSpeed && stateInfo.normalizedTime > 0.5f)
                    {
                        animator.speed = this.CentralNode._RealParams.BackwardSpeed;
                    }
                }
            }
        }
    }
コード例 #21
0
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        timeSinceCapture += Time.deltaTime;
        if (this._BehaviourState == AnimationBehaviourState.INITIAL_POSE)//Testear si esto funciona en este behaviour.
        {
            if (!animator.IsInTransition(0))
                animator.speed = 0;
            return;
        }

        
        if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS && timeSinceCapture > INTERVAL)
        {
            timeSinceCapture = timeSinceCapture - INTERVAL;
            /*
            if (exerciseDataGenerator == null)
                exerciseDataGenerator = GameObject.FindObjectOfType<Detector.ExerciseDataGenerator>();
            if (this.exerciseDataGenerator != null)
                this.exerciseDataGenerator.CaptureData();*/
        }
        float DELTA = 0.05f;
        DateTime temp = DateTime.Now;
        if (_BehaviourState != AnimationBehaviourState.STOPPED && (endRepTime == null || new TimeSpan(0, 0, (int)_RealParams.SecondsBetweenRepetitions) <= temp - endRepTime))
        {
            if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
            {
                OnRepetitionReallyStart();
                BeginRep = true;
            }

            if (stayInPoseState == StayInPoseState.GoingTo &&  stateInfo.normalizedTime + DELTA >= 1)
            {
                animator.speed = 0;
                startHoldTime = Time.time;
                stayInPoseState = StayInPoseState.HoldingOn;
                //Esperar
            }

            //Si ya pasó el tiempo en el ángulo máximo
            else if(stayInPoseState == StayInPoseState.HoldingOn && Time.time - startHoldTime >= _RealParams.SecondsInPose)
            {
                animator.StartRecording(0);
                animator.speed = -this._RealParams.BackwardSpeed;
                animator.StopRecording();
                stayInPoseState = StayInPoseState.Leaving;
            }

            else if (stayInPoseState == StayInPoseState.Leaving && stateInfo.normalizedTime - DELTA <= 0 && haCambiadoDeEstado)
            {
                BeginRep = false;
                animator.speed = 0;
                stayInPoseState = StayInPoseState.Resting;
                startRestTime = Time.time;

                if (((!this.IsWeb) && (!this.IsInInstruction)) && _BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS && (!IsInterleaved || (IsInterleaved && limb == Limb.Right)))
                    this.PauseAnimation();
                if (IsInterleaved && this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
                {
                    haCambiadoDeEstado = false;
                    animator.SetTrigger("ChangeLimb");
                }
                OnRepetitionEnd();
                if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
                    this.Stop();

            }

            else if (stayInPoseState == StayInPoseState.Resting && Time.time - startRestTime>= _realParams.SecondsBetweenRepetitions)
            {
                this.animator.speed = this._realParams.ForwardSpeed;
                stayInPoseState = StayInPoseState.GoingTo;

            }
        }
        
    }
コード例 #22
0
ファイル: Animal.cs プロジェクト: skdeng/SpaceCadets
 //prepare the animal for idle animation
 //param: anim   - animator of the animal
 protected void stopWalking(Animator anim) {
     if (anim.IsInTransition(0)) {
         bMoving = false;
         fLasttime = Time.time;
     }
 }
コード例 #23
0
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
	{
        clockBehaviour.Update();

        if (_BehaviourState == AnimationBehaviourState.INITIAL_POSE)
        {
            if (!animator.IsInTransition(0))
                animator.speed = 0;
            return;
        }
		float DELTA = 0.05f;
		DateTime temp = DateTime.Now;
        if (this._BehaviourState != AnimationBehaviourState.STOPPED && !IsCentralNode)
		{
            if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
			    this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
			    this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
			    this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
			{
				OnRepetitionReallyStart();
				BeginRep = true;
			}

            if (this.CentralNode._StayInPoseState == StayInPoseState.GoingTo && stateInfo.normalizedTime - DELTA >= 1)
			{
                animator.speed = 0;
				startHoldTime = Time.time;
                clockBehaviour.executeRepetitionTime(this.CentralNode._RealParams.SecondsInPose);
                this.CentralNode._StayInPoseState = StayInPoseState.HoldingOn;
			}
			
			//Si ya pasó el tiempo en el ángulo máximo
			else if(this.CentralNode._StayInPoseState == StayInPoseState.HoldingOn && this.CentralNode.holdingPose)
			{
                this.CentralNode.holdingPose = false;
				animator.StartRecording(0);
				animator.speed = -this.CentralNode._RealParams.BackwardSpeed;
				animator.StopRecording();
                this.CentralNode._StayInPoseState = StayInPoseState.Leaving;
            }
			else if (this.CentralNode._StayInPoseState == StayInPoseState.Leaving && 
                stateInfo.normalizedTime - DELTA <= 0)
			{
                BeginRep = false;
				animator.speed = this.CentralNode._RealParams.ForwardSpeed;
                this.CentralNode._StayInPoseState = StayInPoseState.GoingTo;
				startRestTime = Time.time;
                animator.SetInteger("Movement", -1);
				
				if (IsInterleaved && this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
				{
					animator.SetTrigger("ChangeLimb");
				}
				
				if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
                    _BehaviourState = AnimationBehaviourState.STOPPED;

                //OnRepetitionEnd();

            }
		}

    }
コード例 #24
0
 protected override bool ConditionToChangeOn(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     return animator.GetFloat(SpeedVariableName) == WhenSpeedIs && stateInfo.normalizedTime > WhenChange && !animator.IsInTransition(layerIndex);
 }
コード例 #25
0
 private bool isOpen(Animator anim)
 {
     if (!anim.IsInTransition (0))
         return true;
     return anim.GetCurrentAnimatorStateInfo (0).IsName (closedStateName);
 }
コード例 #26
0
ファイル: LerpBehaviour.cs プロジェクト: Tecaa/Configurerer
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        clockBehaviour.Update();
        if (_BehaviourState == AnimationBehaviourState.INITIAL_POSE)
        {
            if (!animator.IsInTransition(0))
                animator.speed = 0;
            return;
        }
                
        #region Interpolate
        //Si no estamos en estado Stopped 
        //Y estamos preparados para hacer Lerp
        //Y el tiempo que ha transcurrido de la ultima rep es mayor al tiempo de pause entre repeticiones. O no ha habido última rep.
       
        if (_BehaviourState != AnimationBehaviourState.STOPPED && ReadyToLerp
            && (endRepTime == null || new TimeSpan(0, 0, (int)_currentParams.SecondsBetweenRepetitions) <= DateTime.Now - endRepTime))
        {
            if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) && 
                this._BehaviourState != AnimationBehaviourState.PREPARING_WEB && 
                this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS && 
                this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
            {
                OnRepetitionReallyStart();
                BeginRep = true;
            }
            //if(_LerpBehaviourState == LerpBehaviourState.STOPPED)
            float timeSinceStarted = Time.time - timeStartedLerping;
            float percentageComplete = 0f;
            /*
            switch (_currentLerpState)
            {
                case LerpState.Forward:
                    
                    percentageComplete = timeSinceStarted / timeTakenDuringForwardLerp;
                    Debug.Log("1 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringForwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime );
                    break;

                case LerpState.Stopped:
                    if (_lastLerpState == LerpState.Forward)
                    {
                        percentageComplete = timeSinceStarted / timeTakenDuringForwardLerp;
                        Debug.Log("2 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringForwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
                    }

                    //De ser true, indica que termino una repeticion
                    else if (_lastLerpState == LerpState.Backward)
                    {
                        percentageComplete = timeSinceStarted / timeTakenDuringBackwardLerp;
                        Debug.Log("3 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringBackwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
                    }
                    break;

                case LerpState.Backward:
                    percentageComplete = timeSinceStarted / timeTakenDuringBackwardLerp;
                    Debug.Log("4 " + percentageComplete + "= " + timeSinceStarted + " / " + timeTakenDuringBackwardLerp + " " + animator.GetCurrentAnimatorStateInfo(0).normalizedTime);
                    break;
            }*/

            percentageComplete = animator.GetCurrentAnimatorStateInfo(0).normalizedTime;

            //float normalizedSpeed;
            //if (percentageComplete < 0.5)
            //    normalizedSpeed = timeSinceStarted/timeTakenDuringForwardLerp * 4;
            //else
            //    normalizedSpeed = 4f- timeSinceStarted / timeTakenDuringForwardLerp * 4;
            //Aplico el suavizado "Smotherstep"
            //percentageComplete = percentageComplete * percentageComplete * (3f - 2f * percentageComplete);
            //float percentageSmotherstep = timeSinceStarted * timeSinceStarted * timeSinceStarted * (timeSinceStarted * (6f * timeSinceStarted - 15f) + 10f);

            float sp = endPosition + startPosition;


            if (!holdingPose)
            {
                animator.StartRecording(0);
                animator.speed = sp;// Mathf.Lerp(startPosition, endPosition, normalizedSpeed);
                                    //Debug.Log("% "+ percentageComplete + "normalized speed " + normalizedSpeed + "  speed " + animator.speed);
                animator.StopRecording();
            }

            float DELTA = 0.03f;
            if ((animator.speed > 0  && percentageComplete >= 1.0f - DELTA) ||
                (animator.speed < 0 && percentageComplete <= 0f + DELTA))
            {
                Debug.Log("int end " + percentageComplete);
                InterpolationEnd();
            }
        }
        else if(this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
        {
            animator.speed = 0;
        }


        if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
        {
            timeSinceCapture += Time.deltaTime;
            if (timeSinceCapture > INTERVAL)
            {
                timeSinceCapture = timeSinceCapture - INTERVAL;
                /*
                if (exerciseDataGenerator == null)
                    exerciseDataGenerator = GameObject.FindObjectOfType<Detector.ExerciseDataGenerator>();
                if (this.exerciseDataGenerator != null)
                    this.exerciseDataGenerator.CaptureData();*/
            }
        }

        
        #endregion
        if (_BehaviourState == AnimationBehaviourState.PREPARING_DEFAULT || _BehaviourState == AnimationBehaviourState.PREPARING_WEB)
            this.SaveTimesAngle(stateInfo);
        lastReadyToLerp = ReadyToLerp;


        JointTypePlanoResult tempJointTypePlanoResult = MovementJointMatch.movementJointMatch[new MovementLimbKey(movement, limb)];
        ArticulacionClass joint = AnimatorScript.instance.utils.getArticulacion(tempJointTypePlanoResult.jointType);
        AnimationInfo tempAnimationInfo = new AnimationInfo();
        float time = stateInfo.normalizedTime; //* stateInfo.length;
        switch (tempJointTypePlanoResult.plain)
        {
            case Plano.planos.planoFrontal:
                tempAnimationInfo = new AnimationInfo(time, joint.AngleFrontal);
                break;
            case Plano.planos.planoHorizontal:
                tempAnimationInfo = new AnimationInfo(time, joint.AngleHorizontal);
                break;
            case Plano.planos.planoSagital:
                tempAnimationInfo = new AnimationInfo(time, joint.AngleSagital);
                break;
            case Plano.planos.planoHorizontalAcostado:
                tempAnimationInfo = new AnimationInfo(time, joint.AngleHorizontalAcostado);
                break;
        }
        //GameObject.FindGameObjectWithTag("angulotexto").GetComponent<Text>().text = "Angulo " + joint.articulacion.ToString() + " : " + tempAnimationInfo.angle.ToString();

    }
コード例 #27
0
		public void CheckForAnimatorStateChanges (Animator animator) {
			for (int layer = 0; layer < LayerCount; layer++) {
				LayerStatuses [layer].State.Current = animator.GetCurrentAnimatorStateInfo (layer).nameHash;
				if (animator.IsInTransition (layer)) {
					LayerStatuses [layer].Transition.Current = animator.GetAnimatorTransitionInfo (layer).nameHash;
				} else {
					LayerStatuses [layer].Transition.Current = 0;
				}
			}
			if (StateHandlers != null && StateHandlers.Count > 0) {
                var enumerator = StateHandlers.GetEnumerator();
                try {
                    while (enumerator.MoveNext()) {

                        var pair = enumerator.Current;
                        var handler = pair.Value;
                        handler.Perform (LayerStatuses, StateInfos);
                    }
                }
                finally {
                    enumerator.Dispose();
                }

			}
			if (TransitionHandlers != null && TransitionHandlers.Count > 0) {
                var enumerator = TransitionHandlers.GetEnumerator();
                try {
                    while (enumerator.MoveNext()) {

                        var pair = enumerator.Current;
                        var handler = pair.Value;
                        handler.Perform (LayerStatuses, TransitionInfos);
                    }
                }
                finally {
                    enumerator.Dispose();
                }
			}
		}
コード例 #28
0
    //Coroutine that will detect when the Closing animation is finished and it will deactivate the
    //hierarchy.
    IEnumerator DisablePanelDeleyed(Animator anim)
    {
        bool closedStateReached = false;
        bool wantToClose = true;
        while (!closedStateReached && wantToClose)
        {
            if (!anim.IsInTransition(0))
                closedStateReached = anim.GetCurrentAnimatorStateInfo(0).IsName(k_ClosedStateName);

            wantToClose = !anim.GetBool(m_OpenParameterId);

            yield return new WaitForEndOfFrame();
        }

        if (wantToClose)
        {
            RectTransform rect = anim.gameObject.GetComponent<RectTransform>();
            rect.SetParent(PoolRoot);
            rect.anchoredPosition = new Vector2(0f, 0f);
            anim.gameObject.SetActive(false);
        }
    }
コード例 #29
0
ファイル: UIWindow.cs プロジェクト: saoniankeji/CommonLib
 IEnumerator Open(Animator anim)
 {
     if (anim != null) {
         bool closedStateReached = anim.GetCurrentAnimatorStateInfo (layer_Index).IsName (k_OpenEndStateName);
         while (!closedStateReached) {
             if (!anim.IsInTransition (layer_Index))
                 closedStateReached = anim.GetCurrentAnimatorStateInfo (layer_Index).IsName (k_OpenEndStateName);
             yield return new WaitForEndOfFrame ();
         }
     }
     InAction.OnCompleteMethod ();
 }