UnityNinja Community
Would you like to react to this message? Create an account in a few clicks or log in to continue.

UnityNinja CommunityLog in

UnityNinja - Video Game Development Community, including Resources, Forums, Marketplace & More.


description[Solved] Getting a cannonball fired from a ship to make a splash (Troubled waters ahead, arr!) Empty[Solved] Getting a cannonball fired from a ship to make a splash (Troubled waters ahead, arr!)

more_horiz
How do I get a cannonball splash effect?This sounds easy, but for me I've been hitting my head against it for over two days. Anyway, I'll keep it simple. Two objects: cannonball with particle effect, ocean with script to trigger splash and to destroy splash and cannonball x seconds after they hit the water.

My idea is this: Cannonball hits ocean, ocean fires particles, ocean grabs particles as a child (so particles stay right where they hit), then oceans destroys ball and emitter after x seconds (cannonball earlier, particles later).

Problem: Took a bit but here is the issue. The particle system doesn't fire. What am I overlooking?

Code:


 using UnityEngine;
 using System.Collections;
 
 public class CannonballEater : MonoBehaviour {
 
     ParticleSystem mySplash;
    
 
     private void OnTriggerEnter(Collider other)
     {
        
        
         mySplash = other.GetComponentInChildren<ParticleSystem>();
         mySplash.Play();
         mySplash.transform.parent = this.transform;
         if (other.tag=="Cannonball")
             Destroy(other.gameObject);
         Destroy(mySplash.gameObject, 5f);
        
                
     }
 }


Last edited by yithpistol on Sat Feb 11, 2017 11:06 am; edited 1 time in total

description[Solved] Getting a cannonball fired from a ship to make a splash (Troubled waters ahead, arr!) EmptyRe: [Solved] Getting a cannonball fired from a ship to make a splash (Troubled waters ahead, arr!)

more_horiz
Is the ocean a trigger?

description[Solved] Getting a cannonball fired from a ship to make a splash (Troubled waters ahead, arr!) EmptyRe: [Solved] Getting a cannonball fired from a ship to make a splash (Troubled waters ahead, arr!)

more_horiz
I got rid of all that parent-reparent stuff. Wasn't my issue.

I simply Instantiate(mySplash,other.transform.position,Quaternion.identity) -ed.

This left the mySpash where the cannonball entered, and voila! splash!

description[Solved] Getting a cannonball fired from a ship to make a splash (Troubled waters ahead, arr!) EmptyRe: [Solved] Getting a cannonball fired from a ship to make a splash (Troubled waters ahead, arr!)

more_horiz
privacy_tip Permissions in this forum:
You cannot reply to topics in this forum
power_settings_newLogin to reply