// Update is called once per frame void Update() { if (collectedCrystals > 4 && !triggered) { triggered = true; triggerTime = Time.time; gate.isEnabled = true; gate.endgame = true; CamShake.Shake(60.0f, 0.4f); } if (collectedCrystals > 4 && triggered) { triggered = true; text.text = "! WARNING !" + Environment.NewLine + "!GET BACK TO THE PORTAL!" + Environment.NewLine + "CAVERN DESTRUCTION IN: " + (60.0f - (Time.time - triggerTime)).ToString(); } }
void DoHurt(int dmg, PlayerPunch punch) { sound.playHurt(); CamShake.AddTrauma(0.7f); motor.DoHurt(punch); healthpool -= dmg; healthBar.updateHealth(healthpool); if (healthpool <= 0) { GameController.controller.Win(4.0f); sound.playDeath(); state = ChinbaldState.Dead; motor.DoDeath(); player.BossDied(); } }
public IEnumerator Stun(float time) { if (!Stunned && !shield.isInvincible) { stunFX.Play(); CamShake camShake = Camera.main.GetComponent <CamShake>(); camShake.StartCoroutine(camShake.Shake(0.1f, 0.05f)); Stunned = true; yield return(new WaitForSeconds(time)); if (Stunned) { Stunned = false; } } }
void Start() { tempVal = transform.position.y; this.transform.localScale = Vector3.Lerp(transform.localScale, targetScale, scaleSpeed); targetScale.Set(minScale, minScale, minScale); shake = FindObjectOfType <CamShake> (); StartCoroutine("Spawn"); StartCoroutine("Animated"); StartCoroutine("LifeTime"); manager = FindObjectOfType <ShootExampleManager> (); }
private void OnCollisionEnter2D(Collision2D other) { var damageable = other.gameObject.GetComponent <Damageable>(); if (damageable != null) { damageable.InflictDamage(inflictedDamage); } if (onDeathParticleSystem != null) { Instantiate(onDeathParticleSystem, transform.position, Quaternion.identity); CamShake.Shake(0.2f, 0.05f); } Destroy(gameObject); }
//we are hit 被攻击 public void Hit(DamageObject d) { //Camera Shake CamShake camShake = Camera.main.GetComponent <CamShake>(); if (camShake != null) { camShake.Shake(.2f); } //check for hit anim.SetAnimatorTrigger("Hit1"); enemyState = UNITSTATE.HIT; //add small force from the impact LookAtTarget(d.inflictor.transform); anim.AddForce(-knockbackForce); }
//jump kick in progress IEnumerator JumpKickInProgress() { animator.SetAnimatorBool("JumpKickActive", true); //a list of enemies that we have hit List <GameObject> enemieshit = new List <GameObject>(); //small delay so the animation has time to play yield return(new WaitForSeconds(.1f)); //check for hit while (playerState.currentState == UNITSTATE.JUMPKICK) { //draw a hitbox in front of the character to see which objects it collides with Vector3 boxPosition = transform.position + (Vector3.up * lastAttack.collHeight) + Vector3.right * ((int)currentDirection * lastAttack.collDistance); Vector3 boxSize = new Vector3(lastAttack.CollSize / 2, lastAttack.CollSize / 2, hitZRange / 2); Collider[] hitColliders = Physics.OverlapBox(boxPosition, boxSize, Quaternion.identity, HitLayerMask); //hit an enemy only once by adding it to the list of enemieshit foreach (Collider col in hitColliders) { if (!enemieshit.Contains(col.gameObject)) { enemieshit.Add(col.gameObject); //hit a damagable object IDamagable <DamageObject> damagableObject = col.GetComponent(typeof(IDamagable <DamageObject>)) as IDamagable <DamageObject>; if (damagableObject != null) { damagableObject.Hit(lastAttack); //camera Shake CamShake camShake = Camera.main.GetComponent <CamShake> (); if (camShake != null) { camShake.Shake(.1f); } } } } yield return(null); } }
public void tickDown() { if (left) { left.tickDown(); CamShake.AddTrauma(0.2f); } if (center) { center.tickDown(); CamShake.AddTrauma(0.2f); } if (right) { right.tickDown(); CamShake.AddTrauma(0.2f); } }
public void collapse() { if (left) { left.fall(); CamShake.AddTrauma(0.5f); } if (right) { left.fall(); CamShake.AddTrauma(0.5f); } if (center) { center.fall(); CamShake.AddTrauma(0.5f); } }
void DoHurt(int dmg) { ClearInputQueue(); attacking = false; state = PlayerState.Hurt; healthpool -= dmg; healthBar.updateHealth(healthpool); CamShake.AddTrauma(1.0f); ani.SetTrigger("PlayerHurt"); if (healthpool <= 0) { GameController.controller.GameOver(); state = PlayerState.Dead; ani.SetTrigger("death"); boss.PlayerDied(); } }
public void OnTap() { if (shakeTicks > 0) { return; } tapDamage++; CamShake.AddTrauma(0.1f); if (tapDamage >= 3) { tapDamage = 0; tickDown(); CamShake.AddTrauma(0.3f); } else { shake(3); } }
public void Awake() { Transform UITrans = GameObject.FindGameObjectWithTag("UI").transform; loopSlider = UITrans.Find("LoopSlider").GetComponent <Slider>(); chargeSlider = UITrans.Find("BreakMeter").GetComponent <Slider>(); shiftButton = UITrans.Find("ButtonShift"); loopSlider.gameObject.SetActive(this.isActiveAndEnabled); chargeSlider.gameObject.SetActive(this.isActiveAndEnabled); shiftButton.gameObject.SetActive(this.isActiveAndEnabled); spriteRenderer = GetComponent <SpriteRenderer>(); animator = GetComponent <Animator>(); loop = GameObject.FindGameObjectWithTag("GameController").GetComponent <LoopController>(); breakMeter = GameObject.FindGameObjectWithTag("UI").transform.Find("BreakMeter").GetComponent <Slider>(); cam = GameObject.FindGameObjectWithTag("MainCamera").transform.parent.GetComponent <CameraBehavior>(); musicController = loop.GetComponent <MusicController>(); soundController = loop.GetComponent <SoundController>(); camShake = cam.transform.Find("Main Camera").GetComponent <CamShake>(); plc = GetComponent <PlayerLifeController>(); }
public override void PlayerPunched(int dmg, PlayerPunch punch) { //TODO: Create a specific timing window during the roar to hurt him. if (state == YetiState.Roar && canHurt) { healthPool -= dmg; healthBar.updateHealth(healthPool); CamShake.AddTrauma(0.7f); if (healthPool <= 0) { DoDie(); } else { //DoHurt (punch); } player.BossHurt(); } }
private void Start() { parrySprite = transform.Find("Parry").GetComponent <SpriteRenderer>(); sprite = GetComponent <SpriteRenderer>(); spriteColor = lifeBarColor; camController = GameObject.Find("CamShake"); camShake = camController.GetComponent <CamShake>(); // Setup lifeBar lifeBar.fillRect.GetComponent <Image>().color = lifeBarColor; life = gameManager.maxLife; UpdateLifeBar(); // Setup particles blockParticles = transform.Find("BlockParticles").GetComponent <ParticleSystem>(); dashParticles = transform.Find("DashParticles").GetComponent <ParticleSystem>(); stunParticles = transform.Find("StunParticles").GetComponent <ParticleSystem>(); collidingParticles = transform.Find("CollidingParticles").GetComponent <ParticleSystem>(); //Audio audioSource = GetComponent <AudioSource>(); }
//easy Flip //private bool facingRight = true; //void Flip() //{ // facingRight = !facingRight; // Vector2 scaler = transform.localScale; // scaler.x *= -1; // transform.localScale = scaler; //} void Start() { Boss = GameObject.FindGameObjectWithTag("Boss").GetComponent <Boss>(); //EmojiSpawn(); _gm = GameObject.FindGameObjectWithTag("GM").GetComponent <GameMaster>(); transform.position = _gm.LastCheckPointPos; //WeaponSprites = new Sprite[2]; _attackTextTimerStart = AttackTextTimer; AttackTextBox.text = ""; _poisonBuffTimer = PoisonTimer; _stealthTimer = SmokeTimer; CurrentHealth = MaxHealth; _extraJumps = ExtraJumpsValue; _rb = GetComponent <Rigidbody2D>(); _animator = GetComponent <Animator>(); _explosion = transform.Find("EpicenterPos").GetComponent <BarellPusher>(); //_spritePlayerWeapon = GetComponent<SpriteRenderer>(); _shake = GameObject.FindGameObjectWithTag("camRig").GetComponent <CamShake>(); _boomAnim = GameObject.FindGameObjectWithTag("explosion").GetComponent <Boom>(); _spritePlayerWeapon = transform.GetChild(4).GetChild(0).GetComponent <SpriteRenderer>(); SpritePlayerHat = transform.GetChild(5).GetComponent <SpriteRenderer>(); SpritePlayerFace = transform.GetChild(5).GetChild(0).GetComponent <SpriteRenderer>(); SpritePlayerEyes = transform.GetChild(5).GetChild(0).GetChild(0).GetComponent <SpriteRenderer>(); }
public void CameraSetUp() { if (playerID == 1) { Debug.Log("Found Cam1"); playerCam = GameObject.FindGameObjectWithTag("Cam1"); playerCam.GetComponent <Camera> ().cullingMask |= ghostLayerMask; playerCam.transform.parent.GetComponent <SmoothCamera>().NewPlayerSetUp(this.transform, cameraDesiredPosition, cameraFocus, cameraPivot, carFront); cameraShake = playerCam.GetComponent <CamShake>(); boostSlider = GameObject.FindGameObjectWithTag("BoostSlider1").GetComponent <Slider>(); } else if (playerID == 2) { playerCam = GameObject.FindGameObjectWithTag("Cam2"); playerCam.GetComponent <Camera> ().cullingMask |= ghostLayerMask; playerCam.transform.parent.GetComponent <SmoothCamera>().NewPlayerSetUp(this.transform, cameraDesiredPosition, cameraFocus, cameraPivot, carFront); cameraShake = playerCam.GetComponent <CamShake>(); boostSlider = GameObject.FindGameObjectWithTag("BoostSlider2").GetComponent <Slider>(); } else if (playerID == 3) { playerCam = GameObject.FindGameObjectWithTag("Cam3"); playerCam.GetComponent <Camera> ().cullingMask |= ghostLayerMask; playerCam.transform.parent.GetComponent <SmoothCamera>().NewPlayerSetUp(this.transform, cameraDesiredPosition, cameraFocus, cameraPivot, carFront); cameraShake = playerCam.GetComponent <CamShake>(); boostSlider = GameObject.FindGameObjectWithTag("BoostSlider3").GetComponent <Slider>(); } else if (playerID == 4) { playerCam = GameObject.FindGameObjectWithTag("Cam4"); playerCam.GetComponent <Camera> ().cullingMask |= ghostLayerMask; playerCam.transform.parent.GetComponent <SmoothCamera>().NewPlayerSetUp(this.transform, cameraDesiredPosition, cameraFocus, cameraPivot, carFront); cameraShake = playerCam.GetComponent <CamShake>(); boostSlider = GameObject.FindGameObjectWithTag("BoostSlider4").GetComponent <Slider>(); } }
//Unit was hit public void Hit(DamageObject d) { if (HitableStates.Contains(enemyState)) { //only allow ground attacks to hit us when we are knocked down if (enemyState == UNITSTATE.KNOCKDOWNGROUNDED && !d.isGroundAttack) { return; } CancelInvoke(); StopAllCoroutines(); animator.StopAllCoroutines(); Move(Vector3.zero, 0f); //add attack time out so this enemy cannot attack instantly after a hit lastAttackTime = Time.time; //don't hit this unit when it's allready down if ((enemyState == UNITSTATE.KNOCKDOWNGROUNDED || enemyState == UNITSTATE.GROUNDHIT) && !d.isGroundAttack) { return; } //defend an incoming attack if (!d.DefenceOverride && defendableStates.Contains(enemyState)) { int rand = Random.Range(0, 100); if (rand < defendChance) { Defend(); return; } } //hit sfx GlobalAudioPlayer.PlaySFXAtPosition(d.hitSFX, transform.position); //hit particle effect ShowHitEffectAtPosition(new Vector3(transform.position.x, d.inflictor.transform.position.y + d.collHeight, transform.position.z)); //camera Shake CamShake camShake = Camera.main.GetComponent <CamShake>(); if (camShake != null) { camShake.Shake(.1f); } //activate slow motion camera if (d.slowMotionEffect) { CamSlowMotionDelay cmd = Camera.main.GetComponent <CamSlowMotionDelay>(); if (cmd != null) { cmd.StartSlowMotionDelay(.2f); } } //substract health HealthSystem hs = GetComponent <HealthSystem>(); if (hs != null) { hs.SubstractHealth(d.damage); if (hs.CurrentHp == 0) { return; } } //ground attack if (enemyState == UNITSTATE.KNOCKDOWNGROUNDED) { StopAllCoroutines(); enemyState = UNITSTATE.GROUNDHIT; StartCoroutine(GroundHit()); return; } //turn towards the direction of the incoming attack int dir = d.inflictor.transform.position.x > transform.position.x? 1 : -1; TurnToDir((DIRECTION)dir); //check for a knockdown if (d.knockDown) { StartCoroutine(KnockDownSequence(d.inflictor)); return; } else { //default hit int rand = Random.Range(1, 3); animator.SetAnimatorTrigger("Hit" + rand); enemyState = UNITSTATE.HIT; //add small force from the impact LookAtTarget(d.inflictor.transform); animator.AddForce(-KnockbackForce); //switch enemy state from passive to aggressive when attacked if (enemyTactic != ENEMYTACTIC.ENGAGE) { EnemyManager.setAgressive(gameObject); } Invoke("Ready", hitRecoveryTime); return; } } }
void cannonActivate() { player.BossAttacked(cannonDamage, Lanes.A); CamShake.MessMeUp(2.0f); }
// Start is called before the first frame update void Start() { rb2d = GetComponent <Rigidbody2D>(); shake = FindObjectOfType <CamShake>(); pool = GameObject.Find("Tilemap").GetComponent <ObjectPoolNS>(); }
// Start is called before the first frame update void Start() { cs = GameManager.instance.cs; }
public void FixedUpdate() { collidedAttractor = null; playerCollidesWithAny = false; foreach (Attractor a in attractors) { if (Physics2D.OverlapCircleAll(a.center, a.pullRadius, 1 << LayerMask.NameToLayer("Player")).Length > 0) { // player is inside any attractor collidedAttractor = a; playerCollidesWithAny = true; break; } } if (playerCollidesWithAny && collidedAttractor == this) { Vector2 forceDirection = Vector3.up; float dist = 1000F; if (playerRb != null) { // calculate direction from player to center of this forceDirection = center - new Vector2(Player._instance.transform.position.x, Player._instance.transform.position.y); // calculate distance to the center of this dist = Mathf.Abs(Vector3.Distance(Player._instance.transform.position, transform.position)); // calculate an amplifier value based on the distance to the center float distAmp = Mathf.InverseLerp(pullRadius, 0, dist); Debug.Log("distAmp " + distAmp); // apply force on player towards center of this playerRb.AddForce(forceDirection.normalized * maxPullForce * Time.fixedDeltaTime * pullAmplifier * distAmp); } // update shader attractorMaterial.SetFloat("_AttractorRadius", pullRadius); Vector3 localPos = transform.InverseTransformPoint(transform.position); localPos.z = transform.position.z; attractorMaterial.SetVector("_AttractionCenter", localPos); attractorMaterial.SetFloat("_PlayerDistance", dist); // update camera shake float shake = Mathf.InverseLerp(pullRadius, 0, dist); CamShake.attractorDistance = shake; SoundPlayer.rumbleAlive = true; SoundPlayer.rumbleVolume = shake; } if (playerCollidesWithAny == true && shaking == false && collidedAttractor == this) { SoundPlayer.rumbleAlive = true; SoundManager.PlayRumbleSound(transform.position); CamShake.AttractorShake(); shaking = true; } else if (playerCollidesWithAny == false) { SoundPlayer.rumbleAlive = false; CamShake.AttractorShakeBreak(); } }
void Start() { camshake = GameObject.Find("Main Camera").GetComponent <CamShake>(); }
void Update() { Vector3 mouseWorldPoint = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector3 diff = mouseWorldPoint - transform.position; Vector3 normalDiff = diff.normalized; float rot_z = Mathf.Atan2(normalDiff.y, normalDiff.x) * Mathf.Rad2Deg; if (!flare.firing) { transform.rotation = Quaternion.Euler(0f, 0f, rot_z); } else { transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.Euler(0f, 0f, rot_z), 0.5f * Time.deltaTime); } if (!Input.GetMouseButton(1) || Input.GetKey(KeyCode.LeftShift)) { camLead = Vector2.zero; } else { float leadFactor = Mathf.Lerp(leadMinDistance, leadMaxDistance, (diff.magnitude - leadMinDistance) / (leadMaxDistance - leadMinDistance)) - leadMinDistance; camLead = transform.right * leadFactor; } follow.offset = camLead; if (!flare.firing) { player.weakened = Input.GetMouseButton(0); float increment = Input.GetMouseButton(0) ? Time.deltaTime * 4f : Time.deltaTime; chargeTimeElapsed = Mathf.Clamp(chargeTimeElapsed + increment, 0f, fullChargeDuration); if (timeSinceMaxCharge >= 0f) { timeSinceMaxCharge += Time.deltaTime; } else if (Input.GetMouseButton(0) && chargeRatio > 0.99f && timeSinceMaxCharge < 0f) { timeSinceMaxCharge = 0f; } if (Input.GetMouseButton(0) && chargeRatio > 0.99f && timeSinceMaxCharge > flareChargeTime) { CamShake.Shake(0.1f, Mathf.Clamp((timeSinceMaxCharge - flareChargeTime) * 0.25f, 0f, 0.25f)); SoundCatalog.SetNoiseVolume(Mathf.Clamp01(timeSinceMaxCharge - flareChargeTime)); } else { SoundCatalog.SetNoiseVolume(0f); } if (Input.GetMouseButtonUp(0)) { if (chargeRatio > 0.99f && timeSinceMaxCharge > flareChargeTime) { flare.Fire(); } else if (chargeTimeElapsed > bulletChargeDrain) { SoundCatalog.PlayGunshotSound(); GameObject bullet = Instantiate(bulletPrefab, transform.position, transform.rotation); bullet.name = "Bullet"; bullet.GetComponent <Rigidbody2D> ().velocity = transform.right * 50f; Destroy(bullet, 5f); CamShake.Shake(0.1f, 0.21f); chargeTimeElapsed = Mathf.Clamp(chargeTimeElapsed - bulletChargeDrain, 0f, fullChargeDuration); } timeSinceMaxCharge = -1f; } } else { chargeTimeElapsed = Mathf.Clamp(chargeTimeElapsed - Time.deltaTime * 12f, 0f, fullChargeDuration); } // if (!flare.firing && Input.GetMouseButton (0) && (chargeTimeElapsed < fullChargeDuration)) { // chargeTimeElapsed += Time.deltaTime; // player.weakened = true; // } // else if (Input.GetMouseButtonUp (0)) { // player.weakened = false; // if (chargeRatio > 0.99f) { // flare.Fire (); // } // else if (chargeRatio > 0.25f) { // GameObject bullet = Instantiate (bulletPrefab, transform.position, transform.rotation); // bullet.name = "Bullet"; // bullet.GetComponent<Rigidbody2D> ().velocity = transform.right * 50f; // Destroy (bullet, 5f); // CamShake.Shake (0.1f, 0.1f); // } // chargeTimeElapsed = 0f; // } chargeMeterY.transform.localScale = new Vector3(1f, Mathf.Lerp(0f, 1f, chargeRatio), 1f); }
void Shake() { CamShake.AddTrauma(1.0f); }
//we are hit public void Hit(DamageObject d) { //check if we can get hit again if (Time.time < LastHitTime + hitThreshold) { return; } //check if we are in a hittable state if (HitableStates.Contains(playerState.currentState)) { CancelInvoke(); //camera Shake CamShake camShake = Camera.main.GetComponent <CamShake>(); if (camShake != null) { camShake.Shake(.1f); } //defend incoming attack if (playerState.currentState == UNITSTATE.DEFEND && !d.DefenceOverride && (isFacingTarget(d.inflictor) || blockAttacksFromBehind)) { Defend(d); return; } else { animator.SetAnimatorBool("Defend", false); } //we are hit UpdateHitCounter(); LastHitTime = Time.time; //show hit effect animator.ShowHitEffect(); //substract health HealthSystem hs = GetComponent <HealthSystem> (); if (hs != null) { hs.SubstractHealth(d.damage); if (hs.CurrentHp == 0) { return; } } //check for knockdown if ((hitKnockDownCount >= knockdownHitCount || !IsGrounded() || d.knockDown) && playerState.currentState != UNITSTATE.KNOCKDOWN) { hitKnockDownCount = 0; StopCoroutine("KnockDownSequence"); StartCoroutine("KnockDownSequence", d.inflictor); GlobalAudioPlayer.PlaySFXAtPosition(d.hitSFX, transform.position + Vector3.up); GlobalAudioPlayer.PlaySFXAtPosition(knockdownVoiceSFX, transform.position + Vector3.up); return; } //default hit int i = Random.Range(1, 3); animator.SetAnimatorTrigger("Hit" + i); SetVelocity(Vector3.zero); playerState.SetState(UNITSTATE.HIT); //add a small force from the impact if (isFacingTarget(d.inflictor)) { animator.AddForce(-1.5f); } else { animator.AddForce(1.5f); } //SFX GlobalAudioPlayer.PlaySFXAtPosition(d.hitSFX, transform.position + Vector3.up); GlobalAudioPlayer.PlaySFXAtPosition(hitVoiceSFX, transform.position + Vector3.up); Invoke("Ready", hitRecoveryTime); } }
void Awake() { shake = this; }
// Use this for initialization void Start() { newUV = new Rect (0, 0f, 0.33333333f, 1f); guishake = GameObject.Find ("guiCamera").GetComponent<CamShake>(); mainshake = GameObject.Find ("Camera").GetComponent<CamShake>(); }
//knockDown sequence public IEnumerator KnockDownSequence(GameObject inflictor) { playerState.SetState(UNITSTATE.KNOCKDOWN); animator.StopAllCoroutines(); yield return(new WaitForFixedUpdate()); //look towards the direction of the incoming attack int dir = inflictor.transform.position.x > transform.position.x ? 1 : -1; currentDirection = (DIRECTION)dir; TurnToDir(currentDirection); //update playermovement var pm = GetComponent <PlayerMovement>(); if (pm != null) { pm.CancelJump(); pm.SetDirection(currentDirection); } //add knockback force animator.SetAnimatorTrigger("KnockDown_Up"); while (IsGrounded()) { SetVelocity(new Vector3(KnockbackForce * -dir, KnockdownUpForce, 0)); yield return(new WaitForFixedUpdate()); } //going up... while (rb.velocity.y >= 0) { yield return(new WaitForFixedUpdate()); } //going down animator.SetAnimatorTrigger("KnockDown_Down"); while (!IsGrounded()) { yield return(new WaitForFixedUpdate()); } //hit ground animator.SetAnimatorTrigger("KnockDown_End"); CamShake camShake = Camera.main.GetComponent <CamShake>(); if (camShake != null) { camShake.Shake(.3f); } animator.ShowDustEffectLand(); //sfx GlobalAudioPlayer.PlaySFXAtPosition("Drop", transform.position); //ground slide float t = 0; float speed = 2; Vector3 fromVelocity = rb.velocity; while (t < 1) { SetVelocity(Vector3.Lerp(new Vector3(fromVelocity.x, rb.velocity.y + Physics.gravity.y * Time.fixedDeltaTime, fromVelocity.z), new Vector3(0, rb.velocity.y, 0), t)); t += Time.deltaTime * speed; yield return(null); } //knockDown Timeout SetVelocity(Vector3.zero); yield return(new WaitForSeconds(KnockdownTimeout)); //stand up animator.SetAnimatorTrigger("StandUp"); playerState.currentState = UNITSTATE.STANDUP; yield return(new WaitForSeconds(KnockdownStandUpTime)); playerState.currentState = UNITSTATE.IDLE; }
//knockDown sequence IEnumerator KnockDownSequence(GameObject inflictor) { enemyState = UNITSTATE.KNOCKDOWN; yield return(new WaitForFixedUpdate()); //look towards the direction of the incoming attack int dir = 1; if (inflictor != null) { dir = inflictor.transform.position.x > transform.position.x? 1 : -1; } currentDirection = (DIRECTION)dir; animator.SetDirection(currentDirection); TurnToDir(currentDirection); //add knockback force animator.SetAnimatorTrigger("KnockDown_Up"); while (IsGrounded()) { SetVelocity(new Vector3(KnockbackForce * -dir, KnockdownUpForce, 0)); yield return(new WaitForFixedUpdate()); } //going up... while (rb.velocity.y >= 0) { yield return(new WaitForFixedUpdate()); } //going down animator.SetAnimatorTrigger("KnockDown_Down"); while (!IsGrounded()) { yield return(new WaitForFixedUpdate()); } //hit ground animator.SetAnimatorTrigger("KnockDown_End"); GlobalAudioPlayer.PlaySFXAtPosition("Drop", transform.position); animator.SetAnimatorFloat("MovementSpeed", 0f); animator.ShowDustEffectLand(); enemyState = UNITSTATE.KNOCKDOWNGROUNDED; Move(Vector3.zero, 0f); //cam shake CamShake camShake = Camera.main.GetComponent <CamShake>(); if (camShake != null) { camShake.Shake(.3f); } //dust effect animator.ShowDustEffectLand(); //stop sliding float t = 0; float speed = 2; Vector3 fromVelocity = rb.velocity; while (t < 1) { SetVelocity(Vector3.Lerp(new Vector3(fromVelocity.x, rb.velocity.y + Physics.gravity.y * Time.fixedDeltaTime, fromVelocity.z), new Vector3(0, rb.velocity.y, 0), t)); t += Time.deltaTime * speed; yield return(new WaitForFixedUpdate()); } //knockDown Timeout Move(Vector3.zero, 0f); yield return(new WaitForSeconds(KnockdownTimeout)); //stand up enemyState = UNITSTATE.STANDUP; animator.SetAnimatorTrigger("StandUp"); Invoke("Ready", standUpTime); }
void Start() { shake = FindObjectOfType <CamShake> (); }
private void Awake() { Instance = this; mainCam = Camera.main; }