Unity Ninja Unity 3D Forum
To have exclusive access to all downloads, recourses and links within this forum, a free registered account is required. Just a heads up Wink

You are not connected. Please login or register

Unity Ninja Unity 3D Forum » HELP » Help (General) » [Solved] Getting a cannonball fired from a ship to make a splash (Troubled waters ahead, arr!)

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

View previous topic View next topic Go down  Message [Page 1 of 1]

yithpistol


Member [Lv. 1]
Member [Lv. 1]
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

View user profile

DeveloperLuke

avatar
Moderator
Moderator
Is the ocean a trigger?

View user profile

yithpistol


Member [Lv. 1]
Member [Lv. 1]
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!

View user profile

Sponsored content


View previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum