Happy new year! I implemented non-repeating pulsations by stacking sine waves inside a for loop. According to my equation, by overlaying just three sine waves, I’m able to produce an equation that doesn’t repeat for almost 50 seconds. That being said, while it may not repeat exactly, the overall pulse has a common up and down pattern. I actually stacked on a fourth wave for extra wonkiness.

To stack sine waves, I just added them together in a for-loop. I used Desmos to crudely read the min/max values of the graph, which fortunately are the same with just an inverted sign. It would be nice to have the bounds calculated by code but I’m not sure how to achieve that yet. Anyways, Here’s how it came out:

Something I’ve noticed might lead to noticeable unrealistic physics later on is that the force of attraction depends only on the mass of the sphere, yet all spheres share a mass of 1 kg. I’m hoping that the attraction radius being tied to sphere radius compensates for this, but to be safe, I added a function SetMass() to set the mass of the body to the average of its scale properties. This adds a bit more realism to the simulation.


Tags: gamedev unity vfx physics scripting math procedural