Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- //Note: The water object must have a BoxCollider attached to it with the "Is Trigger" box is checked.
- //The water object should also be on the "Water" layer.
- public class WaterEntryEffect : MonoBehaviour
- {
- [Header("Leave this object unparented, so it can be positioned freely")]
- // Effect should have simulation space set to "World" so it can be teleported freely
- public ParticleSystem entryEffect;
- void OnTriggerEnter(Collider collider)
- {
- //Trigger if other object is on the "Water" layer
- if (collider.gameObject.layer == 4)
- {
- // Position effect at current collision point and play
- entryEffect.transform.position = this.transform.position;
- entryEffect.Play();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement