void FixedUpdate() { if (isDed) { return; } if (state == "") { state = FindArea(); //When entering water from outside if (state == "water") { if (M.Change(40)) { AudioManager.main.Play("happy"); } AudioManager.main.Play("water"); flasher.Flash(2); GameManager.main.waterSplasher.Play(transform.position); } } if (state == "water") { waterTimer -= Time.deltaTime; if (waterTimer < 0) { waterTimer = Random.Range(1, 3); currWaterTarget = randomPosInsideWater(); } rb.drag = 1.2f; rb.useGravity = false; Vector3 dir = (currWaterTarget - transform.position).normalized; rb.AddForce(transform.forward * swimForce); //rb.AddForce(dir * 0.3f * swimForce); transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.LookRotation(dir, Vector3.up), waterLerpSpeed * Time.fixedDeltaTime); state = FindArea(); } else { rb.useGravity = true; rb.drag = 0; } }
public void UpdateNum() { ClampNum(); onChange.Invoke(); numText.text = number.ToString(); meshFlasher.Flash(); }
void Attack() { meshFlasher.Flash(1); stunTimer = attackStun; if (!GameManager.main.isGameStarted) { return; } List <Health> healths = FindHealths(attackPoint.position, attackRadius); for (int i = 0; i < healths.Count; i++) { healths[i].GetDamage(attackDamage, transform.position.ToVector2()); } }
public void OnPressed() { AudioManager.main.Play("click"); onPressed.Invoke(); anim.SetTrigger("Press"); meshFlasher.Flash(); }
public void Catch(Fish fish) { //print("Catching fish"); flasher.Flash(); currFish = fish; fish.GetHolded(this); AudioManager.main.Play("pop"); }
public void OnDamage(Vector2 pos) { meshFlasher.Flash(); //Add vel AudioManager.main.Play("hit"); Vector2 dir = transform.position.ToVector2() - pos; dir.Normalize(); rb.velocity += dir.ToVector3() * knockbackMult; }