Search Unity

Splash When Tossing Something in the Water

Discussion in 'Animation' started by dupdup7833, Feb 21, 2017.

  1. dupdup7833

    dupdup7833

    Joined:
    Jan 18, 2017
    Posts:
    10
    Looking for some tips on overall approach to creating a splash when an object hits the water in a particular point. I'd like the splash to occur at the entry point and then put the object back to where it started. To get this effect would I create child object that was hidden, like a particle effect or a animated mesh. Then reveal it on the collision with the water. Then relocate the object. I'm not clear on how I get an animation run fully and then do the relocation. Do I need to use a coroutine or something? Any tips or pointing me to a good tutorial would be much appreciated.
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,409
    Simplest way would be to instantiate particle system prefab on the hit point (and then destroy it after few seconds).

    Then to improve it,
    you could use object pooling to save on performance (instead of always creating new objects with instantiate and then destroy, can re-use the particle systems)

    Can you already get the collision point from the hit?
     
  3. dupdup7833

    dupdup7833

    Joined:
    Jan 18, 2017
    Posts:
    10
    I'm actually doing VR development using VRTK and SteamVR so some of the ray trace pieces seems to be taken care of for me.

    I did get this to somewhat work by putting a event/function call at the beginning and end of the animation. Hiding the thrown object at the beginning of the animation and calling a script to start the particle system emission. Then showing the object at the end of the animation at it's new spot.

    The really weird part is the particle system emission works every time after the first time. I've got the particle system as a child of the object as a script variable. So I think it's only instantiated once in the start() function (is that right?). Then I do the local variable thing that seems to be needed for the emitter and enable it. Should I be doing the creation and parenting of the particle system at runtime or is it fine to just do it in the editor?
     
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,409