SetFloat() public method

public SetFloat ( int id, float value ) : void
id int
value float
return void
    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();
        }
    }
 public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     Vector2 movement = animator.GetComponent<MobMotion>().PendingMovement;
     movement.Normalize();
     animator.SetFloat(MovX, movement.x);
     animator.SetFloat(MovY, movement.y);
 }
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     MobMotion motion = animator.GetComponent<MobMotion>();
     Vector2 movement = motion.PendingMovement;
     animator.SetFloat(MovX, movement.x);
     animator.SetFloat(MovY, movement.y);
 }
Esempio n. 4
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) {
		base.OnStateEnter (animator, stateInfo, layerIndex);
		animator.SetFloat (AnimatorConstants.MOVING,Random.value + 0.25f);
		animator.SetFloat (AnimatorConstants.ORTHO, Random.value);
		_rotation = Random.value < 0.5f ? Quaternion.Euler (0, 0, 90) : Quaternion.Euler (0, 0, -90);

	}
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        Animator.SetFloat("speed", Input.GetAxis("Horizontal")); // ser till att animationer spelas när spelaren går - Gustav


        if (Input.GetAxis("Horizontal") < 0)
        {
            direction = -1;
        }
        else if (Input.GetAxis("Horizontal") > 0)   // lagrar vilken riktning som spelaren senast gick i för att se till att den är vänd i rätt riktning - Gustav
        {
            direction = 1;
        }

        if (direction == -1)
        {
            sprite.flipX = true; // vänder spelaren i lämplig rikttning utifrån riktningen som den senast gick mot - Gustav
        }
        else
        {
            sprite.flipX = false;
        }
        if (Input.GetButtonDown("Jump")) // startar animationen för att hoppa - Gustav
        {
            Animator.SetFloat("jump", 1);
        }
        else if (rb.velocity.y < 0.01)
        {
            Animator.SetFloat("jump", rb.velocity.y);
        }
        Animator.SetBool("dashing", dash.DMG);
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        animator.SetFloat("xSpeed", Mathf.Abs(body.velocity.x));

        animator.SetFloat("ySpeed", body.velocity.y);

        animator.SetBool("isSliding", movement.IsSliding);
    }
 // Use this for initialization
 void Start () {
     _axeRes = Resources.Load("Battle_axe") as GameObject;
     Debug.Log(_axeRes);
     _mover = GetComponent<MoveScript>();
     _anim = GetComponent<Animator>();
     _health = GetComponent<HealthScript>();
     _anim.SetFloat("SpeedX", 0);
     _anim.SetFloat("SpeedY", -1);
 }
 public override void Enter()
 {
     PlayerBehaviorStateMachine SM = (PlayerBehaviorStateMachine)GetStateMachine();
     m_Animator = SM.m_GameObject.GetComponent<Animator>();
     m_Animator.SetBool("OnGround", true);
     m_Animator.SetFloat("Jump", 0.0f);
     m_Animator.SetFloat("Turn", 0.0f, 0.1f, Time.deltaTime);
     m_Animator.applyRootMotion = false;
 }
Esempio n. 9
0
    void MovementAnimations()
    {
        var   locVel        = transform.InverseTransformDirection(playerRBody.velocity);
        bool  ground        = ginoController.moveSettings.isGrounded;
        bool  combat        = ginoController.combatSettings.inCombat;
        bool  wallCollision = ginoController.moveSettings.wallCollision;
        bool  climbingWall  = ginoController.moveSettings.climbingWall;
        float upSpeed       = playerRBody.velocity.y;
        float groundDist    = ginoController.height;
        float turnSpeed     = Input.GetAxis("Horizontal");
        float forwardSpeed;
        float climbUp      = locVel.y;
        float climbRight   = locVel.x;
        bool  breakingWall = ginoController.breakingWall;
        bool  block        = ginoController.blockInput;
        bool  charge       = false;
        bool  crouching    = ginoController.moveSettings.isCrouching;

        if (ginoController.runInput > 0 && ginoController.attackInput)
        {
            charge = true;
        }
        if (ginoController.attackInput && ginoController.runInput <= 0 && !animator.GetCurrentAnimatorStateInfo(0).IsName("Slap"))
        {
            combat = true;
        }


        if (!combat)
        {
            forwardSpeed = locVel.z;
        }
        else
        {
            forwardSpeed = Input.GetAxis("Vertical");
        }

        if (Input.GetAxis("Vertical") < -0.1f && !combat)
        {
            turnSpeed = 0;
        }
        //Normal Locomotion
        animator.SetFloat("MoveSpeed", forwardSpeed);
        animator.SetFloat("MoveDirection", turnSpeed);
        animator.SetFloat("groundDist", groundDist);
        animator.SetFloat("climbUp", climbUp);
        animator.SetFloat("climbRight", climbRight);
        animator.SetBool("isGrounded", ground);
        animator.SetBool("wallCollision", wallCollision);
        animator.SetBool("climbingWall", climbingWall);
        animator.SetBool("isCrouching", crouching);
        //Combat Locomotion
        animator.SetBool("inCombat", combat);
        animator.SetFloat("UpSpeed", upSpeed);
        animator.SetFloat("CombatForwardSpeed", forwardSpeed);
        animator.SetFloat("CombatSideSpeed", turnSpeed);
        animator.SetBool("block", block);
        animator.SetBool("charge", charge);
    }
Esempio n. 10
0
    private void ShotAnimation(Animator archer, Transform target)
    {
        Vector2 targetPos = new Vector2(target.position.x, target.position.y);
        Vector2 archerPos = new Vector2(archer.transform.position.x, archer.transform.position.y);

        Vector2 direction = (targetPos - archerPos).normalized;

        archer.SetFloat("AttackDirectionX", direction.x);
        archer.SetFloat("AttackDirectionY", direction.y);
        archer.SetTrigger("AttackTrigger");
    }
Esempio n. 11
0
		public override void OnEnter ()
		{
			animator = ownerDefault.GetComponent<UnityEngine.Animator> ();

			if (dampTime > 0) {
				animator.SetFloat (hash, owner.GetValue(value), dampTime, Time.deltaTime);
			} else {
				animator.SetFloat (hash,  owner.GetValue(value));
			}
			Finish ();
		}
Esempio n. 12
0
	// OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
		GameObject[] players = GameObject.FindGameObjectsWithTag ("Player");
		Attack attack = animator.GetComponent<AttackQueue> ().Attack;
		Enemy enem = animator.GetComponent<Enemy> ();
		Vector3 fromTo = enem.Target.transform.position - animator.transform.position;
		if (fromTo.magnitude <= attack.collSize.magnitude) {
			animator.SetFloat (AnimatorConstants.PUNCH, Random.value);
		} else {
			animator.SetFloat (AnimatorConstants.PUNCH, 0f);
		}
	}
Esempio n. 13
0
    void Init()
    {
        agent = GetComponent<NavMeshAgent>();
        animator = GetComponent<Animator>();
        weapon = GameObject.Find("Weapon").GetComponent<WeaponScript>();
        target = GameObject.Find("Player").transform;

        animator.SetFloat("X", 0);
        animator.SetFloat("Y", 0);

        phase = 1;
    }
 public void BeginAttack()
 {
     agent = GetComponent<NavMeshAgent> ();
     Component[] animatorComponents = GetComponentsInChildren<Animator> ();
     anim = animatorComponents [0] as Animator; // there only exists one animator component
     //BeginAttack();
     attackStarted = true;
     gameObject.SetActive (true);
     agent.SetDestination (attackTarget.position);
     anim.SetFloat ("Walk", 1);
     anim.SetFloat ("Run", 1);
 }
Esempio n. 15
0
	private void Init(){
		Invoke("activation",2f);
		master.setLayer("tower",this.gameObject);
		lifebar = master.getChildFrom("Lifebar", this.gameObject);
		auxbar = lifebar.transform.localScale;
		_animator = this.gameObject.GetComponent<Animator> ();
		_animator.SetBool ("walk", false);
        _animator.SetFloat("WalkDirectionX", 0f);
        _animator.SetFloat("WalkDirectionY", -1f);

        _animator.SetBool ("dead", false);
		_animator.SetBool ("attack", false);
	}
Esempio n. 16
0
        public override void OnUpdate()
        {
            float mValue = useGlobal ? owner.GetFloatOrInt(globalFloat) : value;

            if (dampTime > 0)
            {
                animator.SetFloat(hash, mValue, dampTime, Time.deltaTime);
            }
            else
            {
                animator.SetFloat(hash, mValue);
            }
            Finish();
        }
        public override void OnEnter()
        {
            animator = ownerDefault.GetComponent <UnityEngine.Animator> ();

            if (dampTime > 0)
            {
                animator.SetFloat(hash, owner.GetValue(value), dampTime, Time.deltaTime);
            }
            else
            {
                animator.SetFloat(hash, owner.GetValue(value));
            }
            Finish();
        }
    // Update is called once per frame
    void FixedUpdate()
    {
        onLadder = Physics2D.OverlapCircle (groundCheck.position, ladderRadius, whatIsLadder);
        anim = GetComponent<Animator>();
        float move = Input.GetAxis ("Horizontal");
        float moveY = Input.GetAxis ("Vertical");

        if (!dead) {

            if (grounded) {

                rigidbody2D.velocity = new Vector2 (((Input.GetButton("Run") || (Input.GetAxis("Run") > 0.5f))? (maxSpeed + boost) : maxSpeed) * move ,
               	                                    rigidbody2D.velocity.y);

            }
            if (onLadder) {
                anim.SetFloat ( "SpeedY", moveY );
                rigidbody2D.velocity = new Vector2 (rigidbody2D.velocity.x, moveY * maxSpeed);

            } else {
                anim.SetFloat ( "SpeedY", 0 );
            }
            if (!grounded && !onLadder) {
                rigidbody2D.velocity = new Vector2 (((Input.GetButton("Run") || (Input.GetAxis("Run") > 0.5f))? (maxSpeed + boost) : maxSpeed) * move ,
                                                    rigidbody2D.velocity.y);

            }
            characterRunning = (( move < -0.9f || move > 0.9f) && (Input.GetButton ("Run") || (Input.GetAxis ("Run") > 0.5f)));

            anim.SetFloat("Speed", Mathf.Abs (move));
            anim.SetBool ("running", characterRunning);
            anim.SetBool ("jumping", !(grounded));
            anim.SetBool ("dead", dead);
            anim.SetBool ("onLadder", onLadder);
            anim.SetBool ("onLadderMoving", (onLadder && ( Mathf.Abs (move) !=0 || moveY != 0 )));
            if (Input.GetButtonDown ("Attack")){
                StartCoroutine(SwordAttack());
            }
            anim.SetBool ("sword", Input.GetButtonDown ("Attack"));

            if (move > 0 &&!facingRight){
                Flip ();
                facingRight = true;
            }else if (move < 0 && facingRight){
                Flip ();
                facingRight = false;
            }
        }
    }
Esempio n. 19
0
    //OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        // Patrolling
        if(rb != null)
            rb.velocity = (new Vector2(x, y) * 1f).normalized;

        if (rb.transform.position != lastPos)
        {
            Vector3 direction = rb.transform.position - lastPos;
            direction.Normalize();
            animator.SetFloat("DirectionX", direction.x);
            animator.SetFloat("DirectionY", direction.y);
        }
        lastPos = rb.transform.position;
    }
Esempio n. 20
0
    //public void Move(Vector2 movement_vector, Animator anim, Rigidbody2D rbody)
    //{
    //    if (movement_vector != Vector2.zero)
    //    {
    //        anim.SetBool("isWalking", true);
    //        anim.SetFloat("input_x", movement_vector.x);
    //        anim.SetFloat("input_y", movement_vector.y);
    //    }
    //    else
    //    {
    //        anim.SetBool("isWalking", false);
    //    }
    //    rbody.MovePosition(rbody.position + movement_vector * Time.deltaTime);
    //}
    public void Move(Vector2 movement_vector, Animator anim, Rigidbody2D rbody, float speed)
    {
        if (movement_vector != Vector2.zero)
        {
            anim.SetBool("isWalking", true);
            anim.SetFloat("input_x", movement_vector.x);
            anim.SetFloat("input_y", movement_vector.y);
        }
        else
        {
            anim.SetBool("isWalking", false);
        }

        rbody.MovePosition(rbody.position + movement_vector * speed * Time.deltaTime);
    }
Esempio n. 21
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) {
        hash = GameObject.FindGameObjectWithTag(Tags.player).GetComponent<HashIDs>();
        animator.SetFloat(hash.speedFloat, 0f);

        if (stateInfo.fullPathHash!=hash.EmptyState)
        {

            if(stateInfo.fullPathHash==hash.NormalAttack1State||
                stateInfo.fullPathHash == hash.NormalAttack2State|| 
                stateInfo.fullPathHash == hash.NormalAttack3State)
            {
                PlayerAttack._instance.UseEnergy(SkillType.basic,PosType.basic);
            }
            else
            {
                if (stateInfo.fullPathHash == hash.Skill1State)
                {
                    PlayerAttack._instance.UseEnergy(SkillType.skill, PosType.one);
                }
                else if (stateInfo.fullPathHash == hash.Skill2State)
                {
                    PlayerAttack._instance.UseEnergy(SkillType.skill, PosType.two);
                }
                else if (stateInfo.fullPathHash == hash.Skill3State)
                {
                    PlayerAttack._instance.UseEnergy(SkillType.skill, PosType.three);
                }

            }
        }
    }
Esempio n. 22
0
    /// <summary>
    /// Will set the Animation with the supplied parameter
    /// </summary>
    /// <param name="animation">The Animation to set</param>
    /// <param name="animator">The animator to get the Animations</param>
    /// <param name="parameter">The value for the Animation</param>
    public static void setAnimationTypeAndValue(Animation animation, Animator animator, object value)
    {
        if(value == null) {
            return;
        }

        //Grab what Type of parameter
        AnimatorControllerParameter param = getAnimatorControllerParameter(animation, animator);

        //If param doesn't exist, just get out
        if(param == null) {
            return;
        }

        switch(param.type) {
            case AnimatorControllerParameterType.Bool:
                animator.SetBool(animation.ToString(), (bool)value);
                break;
            case AnimatorControllerParameterType.Float:
                animator.SetFloat(animation.ToString(), (float)value);
                break;
            case AnimatorControllerParameterType.Int:
                animator.SetInteger(animation.ToString(), (int)value);
                break;
            case AnimatorControllerParameterType.Trigger:
                animator.SetTrigger(animation.ToString());
                break;
            default:
                break;
        }
    }
Esempio n. 23
0
        public void Receive(Ray value, Input _input)
        {
            if (_input.InputId == 0)
            {
                Set(UnityObjectsConvertions.ConvertToGameObject(value.GetObject()));
            }

            if (_input.InputId == 1)
            {
                varName.Set(value.GetString());
            }

            if (_input.InputId == 2)
            {
                if (value.IsFloat())
                {
                    varValue.Set(value.GetFloat());
                    animator.SetFloat(varName.GetString(), varValue.GetFloat());
                }
                else
                {
                    Debug.LogWarning("Animator node only supports numbers");
                }
            }
        }
    void HandleReceivingNetworkData(PhotonStream stream, PhotonMessageInfo info)
    {
        // Set initial positions instantly.
        if (!hasInitialUpdate) {
            isPlayerActive = true;

            transform.position = realPosition;
            transform.rotation = realRotation;

            animator = GetComponent<Animator> ();
            animator.SetFloat("Speed", 0);
            animator.SetBool("IsJumping", false);

            shield = GetComponent<Shield> ();
            shield.isActive = false;

            hasInitialUpdate = true;
        }

        // Receive updates from other players.
        gameObject.SetActive((bool)stream.ReceiveNext());
        realPosition = (Vector3)stream.ReceiveNext();
        realRotation = (Quaternion)stream.ReceiveNext();
        animator.SetFloat("Speed", (float)stream.ReceiveNext());
        animator.SetBool("IsJumping", (bool)stream.ReceiveNext());
        shield.isActive = (bool)stream.ReceiveNext();
    }
Esempio n. 25
0
 public void SetFloat(int id, float value)
 {
     if (!_isPlayback)
     {
         _animator?.SetFloat(id, value);
     }
 }
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     GameObject target = animator.GetComponent<LockOn>().Target;
     if (target)
     {
         Transform transform = animator.transform;
         Vector3 heading = target.transform.position - transform.position;
         heading.Normalize();
         animator.SetFloat(NormalX, heading.x);
         animator.SetFloat(NormalY, heading.y);
     }
     else
     {
         animator.SetBool(HasTarget, false);
     }
 }
Esempio n. 27
0
 // OnStateEnter is called before OnStateEnter is called on any state inside this state machine
 //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
 //
 //}
 // OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (stateInfo.normalizedTime >= 0.99f) {
         animator.SetBool ("InJump", false);
         animator.SetFloat ("JumpType", 0);
     }
 }
Esempio n. 28
0
    // Update is called once per frame
    void Update()
    {
        Debug.DrawLine(eyes.position, player.transform.position, Color.green);

        if (alive)
        {
            anim.SetFloat("velocity", nav.velocity.magnitude);

            if (state == "idle")
            {
                //pick a random place to walk to//
                Vector3 randomPos = Random.insideUnitSphere * 20f;
                UnityEngine.AI.NavMeshHit navHit;
                UnityEngine.AI.NavMesh.SamplePosition(transform.position + randomPos, out navHit, 20f, UnityEngine.AI.NavMesh.AllAreas);
                nav.SetDestination(player.transform.position);
                state = "walk";
            }
            //walk//
            if (state == "walk")
            {
                if (nav.remainingDistance <= nav.stoppingDistance && !nav.pathPending)
                {
                    state = "idle";
                }
            }

            if (state == "chase")
            {
                nav.destination = player.transform.position;
            }
        }


        // nav.SetDestination(player.transform.position);
    }
Esempio n. 29
0
 // Use this for initialization
 void Start()
 {
     mOctopusAnim = GetComponent<Animator>();
     mOctopusAnim.SetFloat(mBlendTree, 1.0f);
     mRandomRange = Random.Range(minAttackTime, maxAttackTime);
     mAnimState = AnimationState.Idle;
 }
Esempio n. 30
0
 void Start()
 {
     enemyAnim = GetComponent<Animator>();
     tooClose = false;
     enemyAnim.SetFloat("Speed", 0);
     //		GameObject enemy;
 }
 void Start()
 {
     count = 0;
     anim = GetComponent<Animator>();
     anim.SetFloat ("Speed", 2.0f);
     distance = 0;
     fight = false;
 }
Esempio n. 32
0
 // Use this for initialization
 void Awake()
 {
     anim = GetComponent<Animator>();
     hash = new PlayerHash();
     rigidbody = GetComponent<Rigidbody> ();
     speedHash = Animator.StringToHash ("Speed");
     anim.SetFloat ("Speed", 0);
 }
Esempio n. 33
0
	// Use this for initialization
	void Start ()
	{
	    rb = GetComponent<Rigidbody2D>();
	    boxCollider = GetComponent<BoxCollider2D>();
        s_anim = GetComponent<Animator>();
	    text = GameObject.Find("Textbox").GetComponent<PlayerText>();
        
    
        s_anim.SetFloat ( 
            "vx",
            0
        );
        s_anim.SetFloat ( 
            "vy",
            -1
        );
	}
    void Start()
    {
        sardineAnimator = GetComponent<Animator> ();
        sardineAnimator.SetFloat ("Forward", forwardSpeed);
        sardineRigid = GetComponent<Rigidbody> ();

        pos = gameObject.transform.position;
    }
    // OnStateEnter is called before OnStateEnter is called on any state inside this state machine
    //override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
    //
    //}
    // OnStateUpdate is called before OnStateUpdate is called on any state inside this state machine
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        //Calculate AttackCD
        if (attackCD >= 0)
        {
            attackCD -= Time.deltaTime;
            animator.SetFloat(attackCDHash, attackCD);
        }

        var Target = animator.GetComponent<BattleUnit>().Target;

        //Calculate Distance
        if (Target != null)
        {
            animator.SetFloat(distanceHash, Vector3.Distance(animator.transform.position, Target.transform.position) - attackRange);
        }
    }
 //OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     if (castingTime >= 0)
     {
         castingTime -= Time.deltaTime;
         animator.SetFloat(castingTimeHash, castingTime);
     }
 }
Esempio n. 37
0
    private void Init()
    {
        Invoke("activation", 2f);
        master.setLayer("tower", this.gameObject);
        lifebar = master.getChildFrom("Lifebar", this.gameObject);
        auxbar = lifebar.transform.localScale;
        _animator = this.gameObject.GetComponent<Animator>();

        _animator.SetBool("walk", false);
        _animator.SetFloat("WalkDirectionX", 0f);
        _animator.SetFloat("WalkDirectionY", -1f);

        _animator.SetBool("dead", false);
        _animator.SetBool("attack", false);
        _bulletSpawnPos = transform.FindChild("CannonBallSpawner");
        _towerController = transform.parent.GetComponent<CannonTowerController>();
    }
Esempio n. 38
0
            public static bool AnimeParamSet(
                UnityEngine.Animator animator,
                string name,
                object value,
                AnimatorControllerParameterType type)
            {
                switch (type - 1)
                {
                case 0:
                    animator.SetFloat(name, (float)value);
                    break;

                case 2:
                    animator.SetInteger(name, (int)value);
                    break;

                case 3:
                    animator.SetBool(name, (bool)value);
                    break;

                default:
                    if (type != 9)
                    {
                        return(false);
                    }
                    switch (value)
                    {
                    case null:
                        animator.ResetTrigger(name);
                        break;

                    case bool flag:
                        if (flag)
                        {
                            animator.SetTrigger(name);
                            break;
                        }
                        animator.ResetTrigger(name);
                        break;

                    case int num:
                        if (num != 0)
                        {
                            animator.SetTrigger(name);
                            break;
                        }
                        animator.ResetTrigger(name);
                        break;

                    default:
                        animator.SetTrigger(name);
                        break;
                    }
                    break;
                }
                return(true);
            }
        public void SetAnimatorParameter()
        {
            if (!animator.enabled || !animator.gameObject.activeInHierarchy)
            {
                if (LogDebug)
                {
                    UnityEngine.Debug.Assert(animator.enabled && animator.gameObject.activeInHierarchy,
                                             "Setting the animator parameter while the animator is disabled may not register the change", this);
                }

                return;
            }


            if (isUnsafe)
            {
                return;
            }

            switch (ParameterType)
            {
            case AnimatorControllerParameterType.Float:
                animator.SetFloat(ParameterID, FloatValue.Value);
                break;

            case AnimatorControllerParameterType.Int:
                animator.SetInteger(ParameterID, IntValue.Value);
                break;

            case AnimatorControllerParameterType.Bool:
                animator.SetBool(ParameterID, BoolValue.Value);
                break;

            case AnimatorControllerParameterType.Trigger:
                animator.SetTrigger(ParameterID);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (PreventFewTriggersPerFrame)
            {
                StartCoroutine(MakeUnsafeTillEndOfFrame());
            }

            if (LogDebug)
            {
                UnityEngine.Debug.Log("Parameter Set", this);
            }
        }
Esempio n. 40
0
            public static bool AnimeParamSet(UnityEngine.Animator animator, string name, object value)
            {
                switch (value)
                {
                case float num:
                    animator.SetFloat(name, num);
                    break;

                case int num:
                    animator.SetInteger(name, num);
                    break;

                case bool flag:
                    animator.SetBool(name, flag);
                    break;

                default:
                    return(false);
                }
                return(true);
            }
        public void SetAnimatorParameter(UnityEngine.Animator animator)
        {
            switch (ParameterType)
            {
            case AnimatorControllerParameterType.Float:
                animator.SetFloat(ParameterID, FloatValue.Value);
                break;

            case AnimatorControllerParameterType.Int:
                animator.SetInteger(ParameterID, IntValue.Value);
                break;

            case AnimatorControllerParameterType.Bool:
                animator.SetBool(ParameterID, BoolValue.Value);
                break;

            case AnimatorControllerParameterType.Trigger:
                animator.SetTrigger(ParameterID);
                break;
            }
        }
Esempio n. 42
0
 public void setSpeed(float speed)
 {
     animator.SetFloat(Speed, speed);
 }
 public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     float x = animator.GetFloat(MovX);
     float y = animator.GetFloat(MovY);
     if (Mathf.Abs(x) >= NormalThreshold || Mathf.Abs(y) >= NormalThreshold)
     {
         Vector2 normal = new Vector2(x, y);
         normal.Normalize();
         animator.SetFloat(NormalX, normal.x);
         animator.SetFloat(NormalY, normal.y);
     }
 }