Author Topic: Increasing performace of Buoy System, dramaticly (Tip)  (Read 490 times)


  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Increasing performace of Buoy System, dramaticly (Tip)
« on: October 08, 2017, 09:25:30 AM »
Ok so running my deep profiler, I see your CalculateHeights() in module, is using the most.

What I did was turn your RayCast into a Short(50M) linecast in CalculateHeights, then in fx_buoyancy:

        int RandomInt = UnityEngine.Random.Range(1, 5);
                    if (RandomInt == 1 || !FlaotInit)
                        FlaotInit = true;
                        heightValues = moduleObject.SuimonoGetHeightAll(this.transform.position);
                         OldHeightValues = heightValues;
                    } else
                        heightValues = OldHeightValues;

Turned it into a lateUpdate() and extended my forward buoys out and got the same effect, slightly less accurate but the performance gain is to significant to ignore.

There has to be a better way to get the height than calculating off a texture height map.


  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Increasing performace of Buoy System, dramaticly (Tip)
« Reply #1 on: October 12, 2017, 04:07:47 PM »
I have an idea on how to transform this buoyancy system to work on:
- sample height from any location in the world (doesn't matter where the camera is)
- eliminate the need of Phisics raycast / linecast and mesh colliders to get the heights calculations
- allow dedicated server or clients to compute buoyancy even if the object is not visible (can be easily modified for performance reasons if no player in range - keep at surface level)

My biggest gripe with this water system in a networked environment is distant objects falling through water.

Once I setup this system properly I will make a tutorial on how to adapt it to your needs and hopefully make it run faster! It will work mainly with the "infinite ocean" mode since that is what interests me the most right now (keeping a 100 player/enemies on server/replication infinite ocean without boats falling through the sea mesh).

We will still need to interogate the shader textures to get the height data because the water is shader based - I am thinking to see if I can also improve this somehow to support lots of objects if my soon-to-be-posted-here-tutorial won't get us enough fps back.