private void Jump() { // On Grounded if (controller.isGrounded) { airTime = 0; canJump = true; jumpCount.SetValue(0); } else { airTime += Time.deltaTime; if (airTime >= jumpDisableDelay) { canJump = false; } } if (canJump) { } else if (jumpCount.value == 0) { jumpCount.SetValue(1); } // Jump if (Input.GetButtonDown("Jump") && !jumpCount.IsMaxed) { gravityForce.y = jumpStrength; jumpCount.AddToValue(1); } }
public void TakeDamage(int damage) { if (invincible) { return; } health.AddToValue(-damage); StartCoroutine(Invincibility()); }
public void CreateInstance(Transform transformObj) { if (count != null) { if (count.value <= 0) { return; } count.AddToValue(-1); } Instantiate(gameObject, transformObj.position, transformObj.rotation); }
private void OnTriggerStay(Collider other) { if (other.CompareTag("EnemyPickUp")) { life -= Time.fixedDeltaTime; if (life <= 0) { Destroy(transform.parent.gameObject); } } else if (other.CompareTag("Player")) { count.AddToValue(1); Destroy(transform.parent.gameObject); } }
private void Jump() { isJumping = false; // On Grounded if (controller.isGrounded) { jumpCount.SetValue(0); } else if (jumpCount.value == 0) { jumpCount.SetValue(1); } // Jump if (Input.GetButtonDown("Jump") && !jumpCount.IsMaxed) { isJumping = true; gravityForce.y = jumpStrength; jumpCount.AddToValue(1); } }
private IEnumerator Fire() { characterState.currentState = CharacterStateData.States.Throwing; yield return(startWait); var ray = cam.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out var hit)) { var target = hit.point; transform.LookAt(target); var rot = transform.eulerAngles; rot.x = 0; transform.rotation = Quaternion.Euler(rot); } Instantiate(projectile, firePoint.position, firePoint.rotation); ammoCount.AddToValue(-1); yield return(endWait); characterState.currentState = CharacterStateData.States.Walking; }