當前位置: 首頁>>代碼示例>>C#>>正文


C# Animator.GetBool方法代碼示例

本文整理匯總了C#中UnityEngine.Animator.GetBool方法的典型用法代碼示例。如果您正苦於以下問題:C# Animator.GetBool方法的具體用法?C# Animator.GetBool怎麽用?C# Animator.GetBool使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Animator的用法示例。


在下文中一共展示了Animator.GetBool方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnPhotonSerializeView

    void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.isWriting)
        {
            // We own this player: send the others our data
            stream.SendNext(transform.position);
            stream.SendNext(transform.rotation);
            anim = GetComponent< Animator >();
            stream.SendNext(anim.GetFloat("Speed"));
            stream.SendNext(anim.GetFloat("Direction"));
            stream.SendNext(anim.GetBool("Punch_L"));
            stream.SendNext(anim.GetBool("LowKick"));
            stream.SendNext(anim.GetBool("HiKick"));
            stream.SendNext(anim.GetBool("Shoryuken"));

            myThirdPersonController myC = GetComponent<myThirdPersonController>();
            stream.SendNext((int)myC._characterState);
        }
        else
        {
            // Network player, receive data
            this.correctPlayerPos = (Vector3)stream.ReceiveNext();
            this.correctPlayerRot = (Quaternion)stream.ReceiveNext();
            anim = GetComponent< Animator >();
            anim.SetFloat("Speed",(float)stream.ReceiveNext());
            anim.SetFloat("Direction",(float)stream.ReceiveNext());
            anim.SetBool("Punch_L",(bool)stream.ReceiveNext());
            anim.SetBool("LowKick",(bool)stream.ReceiveNext());
            anim.SetBool("HiKick", (bool)stream.ReceiveNext());
            anim.SetBool("Shoryuken", (bool)stream.ReceiveNext());

            myThirdPersonController myC = GetComponent<myThirdPersonController>();
            myC._characterState = (CharacterState)stream.ReceiveNext();
        }
    }
開發者ID:aka0x0,項目名稱:boomboomwrestling,代碼行數:35,代碼來源:NetworkCharacter.cs

示例2: OnStateExit

    // 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
    //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //}
    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        var currentDirection = (Direction)animator.GetInteger("FaceDirection");

        if (animator.GetBool("MeleeAttackBool"))
        {
          animator.SetBool("MeleeAttackBool", false);
          switch (currentDirection)
          {
        case Direction.Up:
          animator.CrossFade("P_Idle_Up", 0.5f);
          break;
        case Direction.Down:
          animator.CrossFade("P_Idle_Down", 0.5f);
          break;
        case Direction.Left:
          animator.CrossFade("P_Idle_Left", 0.5f);
          break;
        case Direction.Right:
          animator.CrossFade("P_Idle_Right", 0.5f);
          break;
          }
        }
        ResetAnimationState(animator);
    }
開發者ID:musicm122,項目名稱:The-Depths-of-H-E-double-hockey-stick,代碼行數:33,代碼來源:TurnOffAttack.cs

示例3: OnStateExit

 // 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
 //override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
 //
 //}
 // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
 public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (animator.GetBool("death"))
     {
         animator.SetBool("died", true);
         animator.SetBool("death", false);
     }
 }
開發者ID:WizzardMaker,項目名稱:Ludum-Dare,代碼行數:17,代碼來源:deathAnimation.cs

示例4: ConditionToChangeOn

 protected override bool ConditionToChangeOn(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (animator.GetBool(GroundVariableName) && !animator.IsInTransition(layerIndex)) {
         return ChangeOnGround;
     } else {
         return ChangeOnAir;
     }
 }
開發者ID:SpoonmanGames,項目名稱:Descend-Into-Heaven,代碼行數:8,代碼來源:ChangeOnAirGroundBehaviour.cs

示例5: OnStateUpdate

    // 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
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if(animator.GetBool("Grounded"))
        {
            UnityEngine.Random rnd = new UnityEngine.Random();
            //animator.GetComponentInParent<Rigidbody>().AddForce(new Vector3(rnd.RandomRange(-1.0f, 1.0f), rnd.RandomRange(-20.0f, 20.0f), rnd.RandomRange(-1.0f, 1.0f));
            animator.GetComponentInParent<Rigidbody>().AddForce(new Vector3(0f, 20f, 0f));
            animator.SetBool("Grounded", false);
        }
    }
開發者ID:Midimistro,項目名稱:Deadmen,代碼行數:16,代碼來源:ItemRebounce.cs

示例6: GetXAxisForce

    private float GetXAxisForce(Animator animator)
    {
        float xForce =50f;
        if(animator.GetBool(PLATFORM_PARAMETER))
        {
            xForce = 0f;
        }
        if (animator.GetBool(HOLE_PARAMATER))
        {
            xForce = 150f;

            Vector2 newVelocity = mBody.velocity;
            newVelocity.x =  Mathf.Sign(animator.GetFloat("Speed")) * 7f;
            mBody.velocity = newVelocity;
        }

        xForce *= Mathf.Sign(animator.GetFloat("Speed"));

        return xForce;
    }
開發者ID:ysucae,項目名稱:Balloune,代碼行數:20,代碼來源:JumpingState.cs

示例7: OnStateExit

    // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
    public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (castingTime >= 0)
        {
            //Does not finish casting, hero is hit
            if (animator.GetBool(isDelayedHash))
            {
                castingTime += 0.5f;
                animator.SetFloat(castingTimeHash, castingTime);
                return;
            }

            if (animator.GetBool(isInterruptedHash))
            {
                castingTime = 0.0f - float.Epsilon;
                animator.SetFloat(castingTimeHash, castingTime);
                return;
            }
        }
    }
開發者ID:DmaInNewZealand,項目名稱:AutoCombat,代碼行數:21,代碼來源:BattleUnitCastBehaviour.cs

示例8: ToggleVisible

 public void ToggleVisible(Animator anim)
 {
     if (anim.GetBool("isDisplayed"))
     {
         anim.SetBool("isDisplayed", false);
     }
     else
     {
         anim.SetBool("isDisplayed", true);
     }
 }
開發者ID:alleinc,項目名稱:Unity,代碼行數:11,代碼來源:MenuManager.cs

示例9: OnStateEnter

    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        bool OnGround = animator.GetBool("OnGround");
        float jumpVal = animator.GetFloat("Jump");

        if(OnGround && jumpVal > -2)
        {
            //if(soundBank != null)
            //    soundBank.PlaySound("Land");
        }
    }
開發者ID:mdb5108,項目名稱:JurassicParkour,代碼行數:12,代碼來源:StateSoundBehaviour.cs

示例10: OnStateExit

	// 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
	//override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
	//
	//}

	// OnStateExit is called when a transition ends and the state machine finishes evaluating this state
	override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
        animator.gameObject.GetComponent<PressStart>().mode = animator.GetInteger("mode");
		poof = animator.gameObject.GetComponentsInChildren<ParticleSystem>();
        foreach (var puff in poof)
        {
            Debug.Log("Puff");
            puff.Play();
        }
        animator.SetBool("flipped", !animator.GetBool("flipped"));
		//UnityEngine.EventSystems.EventSystem.current.SetSelectedGameObject (GameObject.FindGameObjectWithTag ("UI Element"));
        //anim.SetInteger("mode", menuNumber);
    }
開發者ID:MMEstrada,項目名稱:GoGoGrandmas,代碼行數:23,代碼來源:MenuModeChanger.cs

示例11: OnStateUpdate

 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (_elapsedTime < stateInfo.length + _delayAfterFinish)
     {
         _elapsedTime += Time.deltaTime;
     }
     else if (!animator.GetBool(CharController.DeadBool))
     {
         animator.SetBool(CharController.DyingBool, false);
         animator.SetBool(CharController.DeadBool, true);
     }
 }
開發者ID:LuciusSixPercent,項目名稱:Finsternis,代碼行數:12,代碼來源:DeathAnimationController.cs

示例12: OnStateExit

 public new void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (!animator.GetBool("drawBowBool"))
     {
         if (!this.playerEvents)
         {
             this.playerEvents = animator.transform.GetComponent<animEventsManager>();
         }
         if (this.playerEvents)
         {
             this.playerEvents.enableSpine();
         }
     }
 }
開發者ID:GameDiffs,項目名稱:TheForest,代碼行數:14,代碼來源:bowAnimReset.cs

示例13: Start

    // Use this for initialization
    void Start()
    {
        characterController = GetComponent<CharacterController>();
        game = GameObject.Find("GAME");
        gameScript = game.GetComponent<GameScript>();
        player = gameScript.Player.gameObject;
        animator = transform.FindChild("zombi1animated").gameObject.GetComponent<Animator>();

        target = player.transform.position;

        target.y = transform.position.y;
        animator.SetBool("walking1", Random.Range(0, 2) == 0 ? true : false);
        Debug.Log("walking1: " + animator.GetBool("walking1"));
        move = true;
    }
開發者ID:Jntz,項目名稱:ZombieCampingAdventure,代碼行數:16,代碼來源:ZombieAIScript.cs

示例14: GetParameterValue

    object GetParameterValue(Animator anim, AnimatorControllerParameterType type, int nameHash)
    {
        switch (type) {
            case AnimatorControllerParameterType.Bool:
            case AnimatorControllerParameterType.Trigger:
                return anim.GetBool(nameHash);

            case AnimatorControllerParameterType.Float:
                return anim.GetFloat(nameHash);

            case AnimatorControllerParameterType.Int:
                return anim.GetInteger(nameHash);

            default:
                return null;
        }
    }
開發者ID:Turnary-Games,項目名稱:Battery-Golem,代碼行數:17,代碼來源:SaveAnimator.cs

示例15: DisablePanelDeleyed

	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)
			anim.gameObject.SetActive(false);
	}
開發者ID:wangfeilong321,項目名稱:SpeedBikeRacer,代碼行數:17,代碼來源:PanelManager.cs


注:本文中的UnityEngine.Animator.GetBool方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。