public void Jump() // 점프 함수 { if (r_GM.isPlaying) // 현재 게임중이라면 { if (jumpCnt > 0) // 점프 횟수가 남아 있다면 { // 점프 sound[0].PlayScheduled(0); m_rigid.velocity = Vector2.zero; m_rigid.AddForce(new Vector2(0, jump)); m_animator.PlayInFixedTime("Jump", 0, 0); jumpCnt--; } } }
public void OnCollisionStay(Collision collisionInfo) { if (collisionInfo.collider.name == "Player") { if (!CheckPointFlame.activeSelf) { if (GameMechanics.TourchLightStatus == true) { Popup.GetComponent <Text> ().text = "PRESS <color=#EC2027>E</color> USE THE TORCH"; if (Input.GetKeyDown(KeyCode.E)) { UseTorchAnimation.PlayInFixedTime("UseIgnitedTorch", -1, 0f); CheckPointFlame.SetActive(true); } } else if (GameMechanics.TourchLightStatus == false) { if (GameMechanics.numberTorches == 0) { Popup.GetComponent <Text> ().text = "YOU NEED A TORCH TOO IGNITE"; } else if (GameMechanics.numberTorches > 0) { Popup.GetComponent <Text> ().text = "THE TORCH IS NOT IGNITED"; } } } if (CheckPointFlame.activeSelf) { if (GameMechanics.TourchLightStatus == false) { if (GameMechanics.numberTorches == 0) { Popup.GetComponent <Text> ().text = "YOU NEED A TORCH"; } else if (GameMechanics.numberTorches > 0) { Popup.GetComponent <Text> ().text = "PRESS <color=#EC2027>E</color> TO IGNITE TORCH"; if (Input.GetKeyDown(KeyCode.E)) { //This also triggers an event UseTorchAnimation.PlayInFixedTime("IgniteTorch"); } } } } } }
private void AdjustCC(bool bCheck, CROWD_CONTROL_TYPE type) { if ((cc_state & CROWD_CONTROL_TYPE.SLOW) == CROWD_CONTROL_TYPE.SLOW) { creep_anim.SetBool("cc_Slow", bCheck); speedFactor = bCheck ? 0.5f : 1.0f; creep_anim.SetFloat("SpeedFactor", speedFactor); } if ((cc_state & CROWD_CONTROL_TYPE.ROOT) == CROWD_CONTROL_TYPE.ROOT) { creep_anim.SetBool("cc_Root", bCheck); creep_anim.SetBool("isMovable", !bCheck); } if ((cc_state & CROWD_CONTROL_TYPE.STUN) == CROWD_CONTROL_TYPE.STUN) { creep_anim.SetBool("cc_Stun", bCheck); creep_anim.SetBool("isMovable", !bCheck); if (bCheck) { creep_anim.PlayInFixedTime("Get_hit", 0, 0.1f); creep_anim.StopPlayback(); } } }
/// <summary> /// Function that moves the character. /// </summary> void Moving() { //Parameters for Moving the character float horizontal = Input.GetAxisRaw("Horizontal"); float vertical = Input.GetAxisRaw("Vertical"); direction = new Vector3(horizontal, 0f, vertical).normalized; // If WASD or Arrow keys are pressed if (direction.magnitude >= 0.1f) { // Move the character anim.enabled = true; float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg; float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime); transform.rotation = Quaternion.Euler(0f, angle, 0f); Vector3 moveDir = Quaternion.Euler(0f, targetAngle, 0f) * Vector3.forward; controller.Move(moveDir.normalized * speed * Time.deltaTime); // Checks if the player is in contact with the ground. if (isGrounded) { PV.RPC("setWalking", RpcTarget.All, true); anim.SetBool("isWalking", true); } } else { PV.RPC("setWalking", RpcTarget.All, false); anim.SetBool("isWalking", false); anim.PlayInFixedTime("Move", -1, freeze); } }
void Hit() { rabbitRB.velocity = new Vector3(rabbitRB.velocity.x, 0, 0); rabbitRB.AddForce(new Vector3(0, 25, 0), ForceMode.Impulse); anim.PlayInFixedTime("rabbit_hit"); if (StaticVars.time >= secondsToLose) { StaticVars.time -= secondsToLose; } else { StaticVars.time = 0; } Instantiate(Prefabs.loseSeconds, rabbitRB.transform.position, Quaternion.identity); StaticVars.starBarCount = 0; uiBar.UpdateBar(); isInvincible = true; anim.SetBool("isInvincible", isInvincible); StartCoroutine(InvincibleFrames()); }
private void OnGUI() { // 过渡 if (GUI.Button(new Rect(0, 0, 100, 50), "CrossFade")) { animator.CrossFade("Shake", time); } // https://docs.unity3d.com/ScriptReference/Animator.PlayInFixedTime.html 不是很懂,也没试出什么效果 if (GUI.Button(new Rect(0, 100, 100, 50), "PlayInFixedTime")) { animator.PlayInFixedTime("Shake", 0, time); } // 直接播放 if (GUI.Button(new Rect(0, 200, 100, 50), "Play")) { animator.Play("Shake"); } // 延时播放 if (GUI.Button(new Rect(0, 300, 100, 50), "DelayPlayAnim")) { DelayPlayAnim("Shake", time); } // 恢复播放旋转动作 if (GUI.Button(new Rect(0, 400, 100, 50), "Reset")) { animator.Play("Roate"); } }
void Start() { this._animator = this.gameObject.GetComponent <Animator>(); this._animator.speed = animSpeed; _animator.PlayInFixedTime(0); StartCoroutine(Walk()); }
void Update() { _animator.SetFloat(SpeedParameterHash, 5.0f); #region Input //Shoot if (Input.GetKeyDown(KeyCode.Space)) { _animator.PlayInFixedTime (ShootStateHash, 1, 0f); } //Walk if (Input.GetKeyDown(KeyCode.LeftShift)) { _animator.CrossFade (WalkStateHash, 1f, 0, 0.1f); //(Hash, NormalizedTransitionDuration, Layer, NormalizedTimeOffset) } #endregion #region Dubug //Animator if (_animator.IsInTransition(0) || _animator.IsInTransition(1)) { Debug.Log("Animator is in Transition!"); } #endregion }
} //fin metodo public void OnButtonReleased(VirtualButtonAbstractBehaviour vb) { if (ControlTarget.tocar == true) { Li_animacion.PlayInFixedTime("Li_Idle"); } }
private void PlayAnimByFrame(Animator anim, int frames) { int framesPerSecond = 60; float onceFrameTime = 1f / framesPerSecond; anim.PlayInFixedTime("Clip1", 0, frames * onceFrameTime); }
/// <summary> /// Shoot a bullet /// </summary> void Shoot() { if (disabledBullets.Count <= 0) { if (Bullets == null) { Bullets = new GameObject("bullets"); } GameObject bulletInstance = Instantiate(BulletPrefab, objectGun.position, objectGun.rotation, Bullets.transform); Bullet component = bulletInstance.GetComponent <Bullet>(); component.speed = equipedGun.speed; component.deathTime = equipedGun.deathTime; component.starter = this; activeBullets.Add(bulletInstance); } else { GameObject bullet = disabledBullets[0]; bullet.transform.position = objectGun.position; bullet.transform.rotation = objectGun.rotation; Bullet component = bullet.GetComponent <Bullet>(); component.speed = equipedGun.speed; component.deathTime = equipedGun.deathTime; bullet.SetActive(true); activeBullets.Add(bullet); disabledBullets.Remove(bullet); } anim.PlayInFixedTime(equipedGun.clip.name, -1, 0); }
// Token: 0x06002B22 RID: 11042 RVA: 0x000B5C50 File Offset: 0x000B3E50 public override void OnExit() { if (base.characterBody && !this.outer.destroying && this.endEffectPrefab) { EffectManager.SpawnEffect(this.endEffectPrefab, new EffectData { origin = base.characterBody.corePosition }, false); } Util.PlaySound(BurrowDash.endSoundString, base.gameObject); base.gameObject.layer = LayerIndex.defaultLayer.intVal; base.characterMotor.Motor.RebuildCollidableLayers(); HurtBoxGroup component = this.modelTransform.GetComponent <HurtBoxGroup>(); int hurtBoxesDeactivatorCounter = component.hurtBoxesDeactivatorCounter; component.hurtBoxesDeactivatorCounter = hurtBoxesDeactivatorCounter - 1; base.characterBody.hideCrosshair = false; if (this.burrowLoopEffectInstance) { EntityState.Destroy(this.burrowLoopEffectInstance); } Animator modelAnimator = base.GetModelAnimator(); int layerIndex = modelAnimator.GetLayerIndex("Impact"); if (layerIndex >= 0) { modelAnimator.SetLayerWeight(layerIndex, 2f); modelAnimator.PlayInFixedTime("LightImpact", layerIndex, 0f); } base.OnExit(); }
// Token: 0x0600068A RID: 1674 RVA: 0x0001F2C0 File Offset: 0x0001D4C0 public override void OnEnter() { base.OnEnter(); this.duration = FireArrowOld.baseDuration / this.attackSpeedStat; Ray aimRay = base.GetAimRay(); base.StartAimMode(aimRay, 2f, false); string muzzleName = "Muzzle"; if (FireArrowOld.effectPrefab) { EffectManager.instance.SimpleMuzzleFlash(FireArrowOld.effectPrefab, base.gameObject, muzzleName, false); } Animator modelAnimator = base.GetModelAnimator(); if (modelAnimator) { int layerIndex = modelAnimator.GetLayerIndex("Gesture"); modelAnimator.SetFloat("FireArrow.playbackRate", this.attackSpeedStat); modelAnimator.PlayInFixedTime("FireArrow", layerIndex, 0f); modelAnimator.Update(0f); if (base.hasAuthority) { ProjectileManager.instance.FireProjectile(FireArrowOld.projectilePrefab, aimRay.origin, Util.QuaternionSafeLookRotation(aimRay.direction), base.gameObject, this.damageStat * FireArrowOld.damageCoefficient, FireArrowOld.force, Util.CheckRoll(this.critStat, base.characterBody.master), DamageColorIndex.Default, null, -1f); } } }
void Update() { if (!workDone) { timeToStart += Time.deltaTime; lion.PlayInFixedTime("Li_Attack"); // No realizamos la acción hasta que no pase el tiempo 'TiempoAntesDeAccion' if (timeToStart >= TiempoAntesDeAccion) { lion.Play("Li_Idle"); workDone = true; } } else { timeToEnd += Time.deltaTime; //No avanzamos al siguiente hito hasta que no pase el tiempo 'TiempoDespuesDeAccion' if (timeToEnd >= TiempoDespuesDeAccion) { // Se inicializa el script Start(); lion.Play("Li_Walk"); // Indicamos que se puede pasar el siguiente hito Li.GetComponentInParent <ComportamientoPatron>().CanGoToNextMilestone = true; } } }
/// <summary> /// 从头开始播放一个动画 /// </summary> /// <param name="obj"></param> void Play(string gameObjectPath) { GameObject obj = GameObject.Find(gameObjectPath); if (obj == null) { Debug.LogWarning("动画控制器未找到游戏物体 路径:" + gameObjectPath); return; } Animator animator = obj.GetComponent <Animator>(); if (animator == null) { Debug.LogWarning("动画控制器未找到动画组件 路径:" + gameObjectPath); return; } AnimatorClipInfo[] acInfos = animator.GetCurrentAnimatorClipInfo(0); if (acInfos == null || acInfos.Length < 1) { Debug.LogWarning("动画控制器缺少剪辑 路径:" + gameObjectPath); return; } animator.enabled = true;//启用组件 string clipName = acInfos[0].clip.name; animator.PlayInFixedTime(clipName);//开始播放 }
/** * FUNCTION NAME: OnUpdate * DESCRIPTION : Checks state of animator being listend to. * INPUTS : None * OUTPUTS : None **/ override protected void OnUpdate() { if (!m_bActive) { return; } if (m_cAnimator == null) { return; } if (m_cAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1.0f) { m_bHasFired = false; } if (m_cAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1.0f && !m_bHasFired) { DispatchAnimationCycleEvent(); if (m_cAnimator.GetCurrentAnimatorClipInfo(0)[0].clip.isLooping) { m_cAnimator.PlayInFixedTime(0, -1, m_cAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime - 1.0f); } else { m_bHasFired = true; } } }
//Still Broken as hell public void RunChestAnimation(EntityStates.Barrel.Opening self) { EntityState chestState = self.outer.GetComponent <EntityState>(); ModelLocator modelLocator = self.outer.GetComponent <ModelLocator>(); //protected void PlayAnimation(string layerName, string animationStateName, string playbackRateParam, float duration) //"Body", "Opening", "Opening.playbackRate", Opening.duration //Get Animator of the chest Animator modelAnimator = modelLocator.modelTransform.GetComponent <Animator>(); if (modelAnimator) { //Play Animation int layerIndex = modelAnimator.GetLayerIndex("Body"); modelAnimator.SetFloat("Opening.playbackRate", 1f); modelAnimator.PlayInFixedTime("Opening", layerIndex, 0f); modelAnimator.Update(0f); float length = modelAnimator.GetCurrentAnimatorStateInfo(layerIndex).length; modelAnimator.SetFloat("Opening.playbackRate", length / 1f); } if (chestState.sfxLocator) { Util.PlaySound(chestState.sfxLocator.openSound, base.gameObject); } }
// Setting furniture animation state public void SetPIAnimationState(string PI_name, string state, GameObject obj = null) { // Debug.Log ("SetPIAnimationState " + PI_name + state); if (name_PI_map.ContainsKey(PI_name)) { PhysicalInteractable physicalInteractable = name_PI_map [PI_name]; if (obj == null) { obj = PI_gameObjectMap [physicalInteractable]; } Animator animator = obj.GetComponent <Animator> (); ChangeCurrentGraphicState(physicalInteractable, state); animator.PlayInFixedTime(state); Utilities.SetPISortingOrder(physicalInteractable, obj); } else { Debug.LogError("I don't have this title name " + PI_name); } }
// Update is called once per frame void Update() { if (useSlider == false) { animProgress = animDuration - ((endTime - gameTime.time) * animProgPerSec); } animator.PlayInFixedTime(animStateName, -1, (float)animProgress); if (animProgress > animDuration) { animProgress = animDuration; } else if (animProgress < 0.0f) { animProgress = 0.0f; } if (changeTitleAtStartTime && gameTime.time > startTime) { string newTitle = animName + "\n <size=12>" + animDescription + "</size>"; GameObject.Find("TitleText").GetComponent <titleTextController>().updateTitle("FadeOutIn", newTitle); changeTitleAtStartTime = false; } }
IEnumerator FirstSpin() { blocker.SetActive(true); animHit.Play("DropHit"); yield return(new WaitForSeconds(1.0f)); arrow.SetActive(true); animHit.Play("HitStop"); yield return(new WaitForSeconds(.95f)); animHit.Play(animationNum.ToString()); yield return(new WaitForSeconds(1f)); if (animationNum == 12) { animHit.PlayInFixedTime("CritWheel", 0, 0f); } piece.hitDone = true; if (animationsCalled > 1) { StartCoroutine(SecondSpin()); } else { ResetWheels(); } }
// ------- GRAPHIC STATE ------- // public void ChangeInteractableCurrentGraphicState(string state, PhysicalInteractable interactable) { foreach (GraphicState graphicState in interactable.graphicStates) { Debug.Log(graphicState.graphicStateName + "=>" + state); if (graphicState.graphicStateName == state) { Debug.Log("found state"); // clean previous graphic state EditorRoomManager.instance.room.ChangePIInTiles(interactable, graphicState); interactable.currentGraphicState = graphicState; // go to animation state GameObject obj = GetPhysicalInteractableGameObject(interactable); Animator animator = obj.GetComponent <Animator> (); animator.PlayInFixedTime(state); EventsHandler.Invoke_cb_tileLayoutChanged(); return; } } Debug.LogError("I shouldn't be here."); }
void OnCollisionEnter2D(Collision2D other) { if (other.gameObject.tag == "Player" && !GetComponent <EnemyHealthControl>().tookDamage) { anim.PlayInFixedTime("Atk", 0, 1.0f); } }
private void ChangeCurrentStateRPC(int stateHash, float enterServerTime, byte[] paramBytes) { if (HasAuthority) { return; } if (stateHash == _animator.GetCurrentAnimatorStateInfo(0).fullPathHash) { _animator.PlayInFixedTime(0, 0, Server.Time - enterServerTime); } else { _animator.PlayInFixedTime(stateHash, 0, Server.Time - enterServerTime); } DeserializeParameters(paramBytes); }
void HologramAppear() { characters [currentCharacter].SetActive(true); ChangeCharacter(characters [currentCharacter].name); anim.PlayInFixedTime("in"); print(StaticVars.characterP1); }
/// <summary> /// Plays a state. /// </summary> public void PlayInFixedTime(int hash, int layer, float fixedTime) { if (_animator.HasState(layer, hash)) { _animator.PlayInFixedTime(hash, layer, fixedTime); _unsynchronizedLayerStates.Add(layer); } }
private IEnumerator PlayAniAndWait(string animName) { _animator.PlayInFixedTime(animName, -1, 0.0f); yield return(null); yield return(new WaitForSeconds(_animator.GetCurrentAnimatorStateInfo(0).length)); }
void Start() { /*Scene loadLevel = SceneManager.GetActiveScene (); * SceneManager.LoadScene (loadLevel.buildIndex);*/ Continue.gameObject.SetActive(false); IntroAnimation = GetComponent <Animator> (); IntroAnimation.PlayInFixedTime("IntroCameraAnimation", -1, 0f); }
private IEnumerator DelayThenPlay() { yield return(new WaitForSeconds(2f)); anim.enabled = true; c.enabled = true; anim.PlayInFixedTime("BossUI_Defeated", -1, 0); }
private void PlayAnimation(string layerName, string animationStateName) { int layerIndex = modelAnimator.GetLayerIndex(layerName); modelAnimator.speed = 1f; modelAnimator.Update(0f); modelAnimator.PlayInFixedTime(animationStateName, layerIndex, 0f); }
/// <summary> /// 非预览播放状态下,通过滑杆来播放当前动画帧 /// </summary> private void manualUpdate(NFAnimaStateType stateType, float time) { if (mAnimator != null && stateType != NFAnimaStateType.NONE) { mAnimator.PlayInFixedTime(stateType.ToString(), -1, time); mAnimator.Update(0f); } }
public void OnButtonPressed(VirtualButtonAbstractBehaviour vb) { if (ControlTarget.tocar == true) { Li_animacion = Li.GetComponent<Animator>(); //frente del leon(en la imagen target las patas del dibujo) if (vb.VirtualButtonName == "VB3_3" || vb.VirtualButtonName == "VB4_3") { //de fernte Li.transform.rotation = Quaternion.LookRotation((giroFrente.transform.position - Li.transform.position)); if(enfadado == false) { Li_animacion.Play("Li_Drink"); if(ControlTarget.currentFelicidad +1 == 100) { ControlTarget.currentFelicidad = 100; } else { ControlTarget.currentFelicidad += 1; } } else { Li_animacion.PlayInFixedTime("Li_Attack"); } } //espalda del leon(en la imagen target arriba de la figura) if (vb.VirtualButtonName == "VB2_3" || vb.VirtualButtonName == "VB1_3") { //de fernte Li.transform.rotation = Quaternion.LookRotation((giroAtras.transform.position - Li.transform.position)); if(enfadado == false) { Li_animacion.Play("Li_Drink"); if(ControlTarget.currentFelicidad +1 == 100) { ControlTarget.currentFelicidad = 100; } else { ControlTarget.currentFelicidad += 1; } } else { Li_animacion.PlayInFixedTime("Li_Attack"); } } //izquierda del leon if(vb.VirtualButtonName == "VB1_1" || vb.VirtualButtonName == "VB1_2" || vb.VirtualButtonName == "VB4_2" || vb.VirtualButtonName == "VB4_1") { //nos giramos Li.transform.rotation = Quaternion.LookRotation((giroIzquierda.transform.position - Li.transform.position)); //comprobamos el animo del leon y hacemos una animacion respecto a como este if(enfadado == false) { Li_animacion.Play("Li_Drink"); if(ControlTarget.currentFelicidad +1 == 100) { ControlTarget.currentFelicidad = 100; } else { ControlTarget.currentFelicidad += 1; } } else { Li_animacion.PlayInFixedTime("Li_Attack"); } } //derecha del leon if (vb.VirtualButtonName == "VB2_1" || vb.VirtualButtonName == "VB2_2" || vb.VirtualButtonName == "VB3_1" || vb.VirtualButtonName == "VB3_2") { Li.transform.rotation = Quaternion.LookRotation((giroDerecha.transform.position - Li.transform.position)); //comprobamos el animo del leon y hacemos una animacion respecto a como este if(enfadado == false) { Li_animacion.Play("Li_Drink"); if(ControlTarget.currentFelicidad +1 == 100) { ControlTarget.currentFelicidad = 100; } else { ControlTarget.currentFelicidad += 1; } } else { Li_animacion.PlayInFixedTime("Li_Attack"); } } }//fin if }