Author Topic: Raycasting Waves  (Read 11 times)

deibu

  • Newbie
  • *
  • Posts: 1
    • View Profile
Raycasting Waves
« on: August 09, 2018, 01:22:35 PM »
Hello,

I am trying to shoot projectiles into the ocean and see splashes when they hit the waves. I was only able to find the surface height at a given position, but I do not know when my projectile hits the water. Is there an easy way to raycast and get the exact touch point of my projectile hitting a wave?

Thanks!
« Last Edit: August 09, 2018, 06:40:24 PM by deibu »

Chingwa

  • Administrator
  • Hero Member
  • *****
  • Posts: 1591
    • View Profile
    • Tanuki Digital
Re: Raycasting Waves
« Reply #1 on: August 10, 2018, 03:35:21 PM »
The main problem with raycasts is that Suimono wave offsets are generated on the GPU, thus the raycast is not hitting the actual waves but instead the underlying surface position.  Probably the best alternative is to send out a ray from your gun position and then sampling a series of Vector3 points along the ray using the SuimonoGetHeight() function on each point.  Once you hit the first point where the return value is under the water you would use that point as your projectile hit position.

OR if your projectile is slow enough you could just sample the current Vector3 position of the projectile (using SuimonoGetHeight) until it the first time it is underwater.