/// <summary> /// Calculating Euler physics on Y axis. /// </summary> private void MovementVertical() { float gravMultiplier = 1; bool wantsToJump = Input.GetButtonDown("Jump"); bool isHoldingJump = Input.GetButton("Jump"); if (wantsToJump && isGrounded) { velocity.y = jumpInpulse; isJumpingUpwards = true; isGrounded = false; SoundEffectBoard.PlayJump(); } if (!isHoldingJump) { isJumpingUpwards = false; } if (isJumpingUpwards) { gravMultiplier = 0.5f; } //apply force of gravity to velocity velocity.y -= gravity * Time.deltaTime * gravMultiplier; //clamp vertical speed to create terminal velocity if (velocity.y < -terminalVelocity) { velocity.y = -terminalVelocity; } }
void Start() { if (main == null) { main = this; player = GetComponent <AudioSource>(); } else { Destroy(this.gameObject); } }
public void OnOverlap(EnemyBasicController be) { HealthSystem health = be.GetComponent <HealthSystem>(); if (health) { health.TakeDamage(damageAmount); } //Vector3 vToPlayer = (be.transform.position - this.transform.position).normalized; //be.LaunchPlayer(vToPlayer * 15); SoundEffectBoard.PlayHit(); }
public override void OnOverlap(PlayerMovement pm) { HealthSystem health = pm.GetComponent <HealthSystem>(); if (health) { health.TakeDamage(damageAmount); } Vector3 vToPlayer = (pm.transform.position - this.transform.position).normalized; pm.LaunchPlayer(vToPlayer * 15); SoundEffectBoard.PlayHit(); }
public void OnTriggerEnter(Collider other) { HealthSystem health = other.GetComponent <HealthSystem>(); PlayerMovement pm = other.GetComponent <PlayerMovement>(); if (health) { health.TakeDamage(damageAmount); } //Vector3 vToPlayer = (be.transform.position - this.transform.position).normalized; //be.LaunchPlayer(vToPlayer * 15); SoundEffectBoard.PlayHit(); }
void SpawnProjectile() { if (timerSpawnBullet > 0) { return; // wait longer to fire again... } if (roundsInClip <= 0) { return; // no ammo! } Projectile p = Instantiate(prefabProjectile, transform.position, Quaternion.identity); p.InitBullet(transform.forward * 20); roundsInClip--; timerSpawnBullet = 1 / roundsPerSecond; SoundEffectBoard.PlayShot(); }
public void OnTriggerEnter(Collider other) { HealthSystem health = other.GetComponent <HealthSystem>(); EnemyBasicController be = other.GetComponent <EnemyBasicController>(); BossController boss = other.GetComponent <BossController>(); if (health && be || health && boss) { health.TakeDamage(damageAmount); Destroy(gameObject); } //Vector3 vToPlayer = (be.transform.position - this.transform.position).normalized; //be.LaunchPlayer(vToPlayer * 15); SoundEffectBoard.PlayHit(); }
public void Die() { Destroy(gameObject); SoundEffectBoard.PlayDie(); }
public override void OnOverlap(PlayerMovement pm) { pm.LaunchPlayer(new Vector3(0, 20, 0)); SoundEffectBoard.PlaySpring(); }