本文整理汇总了C#中UnityEngine.Animator.SetBool方法的典型用法代码示例。如果您正苦于以下问题:C# Animator.SetBool方法的具体用法?C# Animator.SetBool怎么用?C# Animator.SetBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Animator
的用法示例。
在下文中一共展示了Animator.SetBool方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start()
{
animator = GetComponent<Animator>();
dragon = GetComponent<Dragon>();
animator.SetBool("Flying",false);
animator.SetBool("Breath Fire", false);
}
示例2: OnStateExit
// 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.SetBool ("lowTrip", false);
// In case the animation ends early, we must avoid input holds
this.active = false;
animator.SetBool ("inAnimation", false);
}
示例3: Update
// Update is called once per frame
void Update()
{
if (Input.GetMouseButtonDown(0) && _weaponSelected != null) {
AudioSource.PlayClipAtPoint(fire, Vector3.up);
}
if (Input.GetKeyDown(KeyCode.E) && _weaponSelected == null) {
_colSelected = Physics2D.OverlapPoint(transform.position);
if (_colSelected && _colSelected.tag == "weapon") {
AudioSource.PlayClipAtPoint(reload, Vector3.up);
_weaponSelected = _colSelected.gameObject.GetComponent<generateWeapon>();
anim = _weaponSelected.GetComponent<Animator>();
_weapon = _weaponSelected.weapon.GetComponent<weapons>();
attachToBody.GetComponent<SpriteRenderer>().sprite = _weapon.attachToBody;
weapon2 = weapon.GetComponent<weapon>();
bullet_prefab = weapon.GetComponent<weapon>().bullet_prefab;
bullet_prefab.GetComponent<SpriteRenderer>().sprite = weapon2.bullets[_weaponSelected.i];
_weaponSelected.transform.localScale = Vector3.zero;
anim.SetBool("isTake", true);
anim.SetBool("isDrop", false);
}
}
if (Input.GetMouseButtonDown (1) && _weaponSelected != null) {
anim.SetBool("isTake", false);
anim.SetBool("isDrop", true);
_weaponSelected.transform.position = transform.position;
attachToBody.GetComponent<SpriteRenderer>().sprite = null;
_weaponSelected = null;
}
}
示例4: Start
// Use this for initialization
void Start()
{
Cursor.visible = false; // temporarily set to true for testing
eyes = this.transform.Find("Eyes").gameObject;
body = this.transform.Find("geckstronautAnimatedWithGun").gameObject;
startPosition = this.transform.position; // this will be the place the player responds to each time he dies
eyesStartPos = eyes.transform.position;
bodyStartPos = body.transform.position;
startRot = this.transform.rotation;
eyesStartRot = eyes.transform.rotation;
bodyStartRot = body.transform.rotation;
characterController = GetComponent<CharacterController>();
firstPersonCamera = this.GetComponentInChildren<Camera>();
geckAnimator = this.transform.Find("geckstronautAnimatedWithGun").GetComponent<Animator>();
geckAnimator.SetBool("HasGun", false);
geckAnimator.SetBool("Idle", false);
geckAnimator.SetBool("Walking", false);
geckAnimator.SetBool("Running", false);
geckAnimator.SetBool("Shooting", false);
manager = GameObject.FindGameObjectWithTag("GameController");
mouseSensitivity = PlayerPrefs.GetFloat ("Mouse Sensitivity");
//manager.GetComponent<GameManagerScript>().mouseSensitivity; // get mouse sensitivity from GameController object
//if (isLocalPlayer) {
// this.GetComponentInChildren<Camera>().enabled = true;
// this.GetComponentInChildren<AudioListener>().enabled = true;
//}
}
示例5: Start
// Use this for initialization
void Start ()
{
playerHP = maxPlayerHP;
//ustawienie wizje na latarke
visionALongLight.enabled = true;
visionAShortLight.enabled = true;
visionBLight.enabled = false;
visionBTopLight.enabled = false;
visionCLight.enabled = false;
mainCamera_ = GameObject.Find("Main Camera");
animator_ = GameObject.Find("laska").GetComponent<Animator>();
//animator_ =
//animator_cycki = GameObject.Find("laska_cycki").GetComponent<Animator>();
//animator_nogi = GameObject.Find("laska_nogi").GetComponent<Animator>();
animator_.SetBool("isWalking", false);
animator_.SetBool("isShooting", false);
animator_.SetBool("isAttacked", false);
animator_.SetBool("isDying", false);
//animator_cycki.SetBool("isWalking", false);
//animator_cycki.SetBool("isShooting", false);
//animator_cycki.SetBool("isDying", false);
//animator_nogi.SetBool("isWalking", false);
//animator_nogi.SetBool("isShooting", false);
//animator_nogi.SetBool("isDying", false);
}
示例6: OnStateExit
// 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 (layerIndex == 1)
animator.SetBool("Fire Attack", false);
else if (layerIndex == 2)
animator.SetBool("Ice Attack", false);
}
示例7: Awake
// Use this for initialization
void Awake()
{
rb2d = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> ();
anim.SetBool ("surprised", false);
anim.SetBool ("facingRight", false);
}
示例8: Start
// On scene load, do this...
void Start() {
leftArmNode = transform.Find(leftArmNodeName).GetComponent<PickupNode>();
rightArmNode = transform.Find(rightArmNodeName).GetComponent<PickupNode>();
leftArmNode.setPosition(transform.Find(leftArmNodeName));
rightArmNode.setPosition(transform.Find(rightArmNodeName));
leftArmPosition = "North";
rightArmPosition = "North";
float old_ly = leftArmNode.getTransform().localPosition.y;
leftArmNode.getTransform().localPosition = new Vector3(-0.3f, old_ly, 1.0f);
float old_ry = rightArmNode.getTransform().localPosition.y;
rightArmNode.getTransform().localPosition = new Vector3(0.3f, old_ry, 1.0f);
animate = GetComponent<Animator>();
itemManager = GetComponent<PlayerItemManager> ();
animate.SetBool("LF", LF);
animate.SetBool("RF", RF);
// NOTE:
// "Node Position" is really only the coordinates of game objects called
// "Left Arm Node", "Right Arm Node" and such. The Nodes themselves are a part
// of this own manager's abstract class.
//
// In other words, no properties are ever allocated to those node objects in the
// game space. They are only the points at which
}
示例9: basicMelee
// basic melee attack which just deals damage and runs animation. простая атака ближнего боя которая наносит урон и проигрывает анимацию
public void basicMelee()
{
this.towerManager.isphysDmg=true;
this.towerManager.ismageDmg=false;
if(attackAreaMeleeEnter.enemy!=null) // check if there is something in front of the tower. проверить есть ли какой-то объект перед башней.
{
if(attackAreaMeleeEnter.enemy.gameObject.tag.Contains("Enemy")) //check if thing in front of tower is actually an enemy. проверить если этот объект с тегом враг
{
hp = attackAreaMeleeEnter.enemy.gameObject.GetComponent("Health") as Health; // get health component of an enemy. берем компонент health из объекта врага
animator = this.GetComponent<Animator>();// animator
// attack with cooldown of two seconds and play animation. атакует с интервалом в две секунды и играет анимацию.
if (timeStamp<=Time.time)
{
hp.getDamage(damage);
timeStamp=Time.time+2.0f;
animator.SetBool("Attack",false);
}
// if enemy is dead, destroy enemy object. если враг мертв, уничтожаем его объект и ставим idle анимацию.
if (hp.isDead())
{
Destroy(attackAreaMeleeEnter.enemy.gameObject);
animator.SetBool("Attack",true);
}
}
}
}
示例10: OnTriggerEnter2D
void OnTriggerEnter2D(Collider2D other)
{
if(other.gameObject.tag == "Shot"){
if(other.transform.position.x < Lion.transform.position.x)
Lion.rigidbody2D.AddForce( new Vector2(hit_power, 0));
else
Lion.rigidbody2D.AddForce( new Vector2( -1 * hit_power, 0));
Lion_Script.HP -= 1;
BHScript.currenthealth -= 1;
Lion.audio.PlayOneShot (lionroar);
Lion_Script.fleeing = true;
Lion_Script.flee_time += flee_increase;
gameObject.active = false;
if(Lion_Script.HP <=0){
anim = Lion.GetComponent<Animator>();
anim.SetBool ("roarState", false);
anim.SetBool("deathState", true);
anim.SetBool("permaState", true);
Lion_Script.enabled = false;
}
Destroy(other.gameObject);
}
}
示例11: Start
// Use this for initialization
void Start () {
LeverAnimator = GetComponent<Animator>();
if (PlayerPrefsX.GetBool("LeverLoading"))
{
if (gameObject.name == "LeftLever")
{
LeverAnimator.SetBool("Pulled", PlayerPrefsX.GetBool("LeftLeverPulled"));
PlayerPrefsX.SetBool("LeftLeverDealtWith", true);
}
if (gameObject.name == "RightLever")
{
LeverAnimator.SetBool("Pulled", PlayerPrefsX.GetBool("RightLeverPulled"));
PlayerPrefsX.SetBool("RightLeverDealtWith", true);
}
if (PlayerPrefsX.GetBool("LeftLeverDealtWith") && PlayerPrefsX.GetBool("RightLeverDealtWith"))
{
PlayerPrefsX.SetBool("LeverLoading", false); //this line is what is causing the issues with the left lever
PlayerPrefsX.SetBool("LeftLeverDealtWith", false);
PlayerPrefsX.SetBool("RightLeverDealtWith", false);
}
}
}
示例12: initVariables
public void initVariables(Character currChar, string side, string itemName1)
{
character = currChar;
animator = character.GetComponent<Animator> ();
itemName = itemName1;
targetRightHouse = new Vector3 (16.5f, 0.45f, -6.0f);
targetLeftHouse = new Vector3 (12.0f, 0.45f, -6.0f);
targetLeftItemDrop = new Vector3 (14.0f, 0.45f, -6.0f);
targetRightItemDrop = new Vector3 (15.4f, 0.45f, -6.0f);
//updateAnimationPoints ();
animator.SetBool ("insideHouse", true);
if (side.Contains ("left") && itemName.Contains ("none")) {
leftToRight = true;
} else if (side.Contains ("right") && itemName.Contains ("none")) {
rightToLeft = true;
} else if (side.Contains ("left")) {
leftToRightBindle = true;
animator.SetBool ("bindle", true);
} else if (side.Contains ("right")) {
rightToLeftBinle = true;
animator.SetBool ("bindle", true);
}
isInit = true;
}
示例13: CheckTimeIddle
private void CheckTimeIddle(Animator animator)
{
if (commonParameters.walking) {
//if enemy walk, check the timer
_deltaTime -= Time.deltaTime;
if (_deltaTime <= 0) {
animator.SetBool("Timer", true);
}
//but if only one path...
if (commonParameters.AI.walkingParameters.usePath && commonParameters.AI.walkingParameters.path.points.Length<=1) {
commonParameters.walking = false;
}
} else {
//if the enemy is not walking but not in its position, go to walking
Vector3 target = commonParameters.initialPositionEnemy;
Quaternion rotationTarget = commonParameters.initialRotationEnemy;
if (!AIMethods.CheckTargetPoint(commonParameters.enemy, target, commonParameters.onFloor, commonParameters.minimumWalkingDistance)) {
animator.SetBool("Timer", true);
}
if (!AIMethods.CheckTargetRotation(commonParameters.enemy, rotationTarget, commonParameters.toleranceDegreeToGoal)) {
animator.SetBool("Timer", true);
}
}
}
示例14: 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();
}
}
示例15: OnStateEnter
public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
if (A)
animator.SetBool (AnimParameter.A,false);
if (S)
animator.SetBool (AnimParameter.S,false);
}