private void OnCollisionEnter(Collision other) { if (other.gameObject.tag == collisionTag) { com.Play3D(transform, GetComponent <Rigidbody>()); } }
private void OnTriggerEnter(Collider other) { if (other.tag == player.ToString()) { try { other.GetComponent <Buffable>().AddBuff(scriptableBuff); } catch { Debug.LogError("Buffable component not found!"); } com.Play3D(transform, rb); Destroy(gameObject); } }
private void FixedUpdate() { actionPoint = transform.position + transform.TransformDirection(buoyancyOffset); forceFactor = 1f - ((actionPoint.y - waterLayer) / floatHeight); if (forceFactor > 0) { splashSound.Play3D(transform, rb); uplift = -Physics.gravity * (forceFactor - rb.velocity.y * bounceDamp); rb.AddForceAtPosition(uplift, actionPoint); } }
private void Explode() { com.Play3D(transform, rb); Collider[] colliders = Physics.OverlapSphere(transform.position, radius, playerLayer); foreach (Collider col in colliders) { try { col.GetComponent <IDestroyable>().Destroy(); } catch { Debug.Log("IDestroyable component not found!"); } } GameObject particle = Instantiate(explosionParticle, transform.position, Quaternion.identity); Destroy(particle, 1f); Destroy(gameObject); }
void FixedUpdate() { if (input.GoingUp) { OnBurn(true); burnerSound.SetParameter("Burning", 1f); burnerSound.Play3D(transform, rb); if (rb.velocity.y > 0.0f) { rb.AddForce(transform.up * (1.4f * burnerPower), ForceMode.Acceleration); } else { rb.AddForce(transform.up * (0.8f * burnerPower), ForceMode.Acceleration); } } else { burnerSound.SetParameter("Burning", 0f); OnBurn(false); } }