Hello.
I have just recently started my internship for a small indy developer in Norway, and have been given the task of creating a prototype level for a future project. My experience is visual level design, and close to no scripting what so ever. I'm a major noob with scripting.
I need to figure out how to activate a particle effect with a contact/collision trigger. To be more precise, activate a water splash after hitting the water with the character. Anyone who can give me a hint on how to set up the script? Preferably in C#, but JS could also work since it's only a prototype project.
-Noob intern-
what you can do is place a trigger collider on the water (mesh of box) and instantiate a splash prefab (one shot particle emitter) at the point of contact. Also if the water is perfectly level like in a small lake you can set the exact height of the water, otherwise you'll need to use a raycast to fine the surface point e.g.
var splashPrefab : GameObject;
var splashPoint : Vector3;
var waterHeight : float = 2.0; // the height of the water if it doesn't move
function OnTriggerEnter(other : Collider){
if(other.gameObject.CompareTag("player")){
splashPoint=other.transform.position;
splashPoint.y = waterHeight;
Instantiate(splashPrefab,splashPoint,other.transform.rotation);
}
}
You can also do a 2nd splash which is smaller and use it with OnTriggerStay so it plays while the player stands in the water as well.