本文整理汇总了C#中UnityEngine.Animator.SetFloat方法的典型用法代码示例。如果您正苦于以下问题:C# Animator.SetFloat方法的具体用法?C# Animator.SetFloat怎么用?C# Animator.SetFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Animator
的用法示例。
在下文中一共展示了Animator.SetFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnStateEnter
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);
}
示例2: 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();
}
}
示例3: OnStateEnter
// 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);
}
示例4: BeginAttack
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);
}
示例5: OnStateUpdate
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);
}
示例6: Start
// 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);
}
示例7: Enter
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;
}
示例8: OnEnter
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 ();
}
示例9: ShotAnimation
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");
}
示例10: OnStateUpdate
// 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);
}
}
示例11: Init
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;
}
示例12: Init
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);
}
示例13: FixedUpdate
// 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;
}
}
}
示例14: OnStateUpdate
//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;
}
示例15: Move
//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);
}