How to simulate wind blowing/physics

How I would able to simulate wind blowing physics like leaves move, grass moves, and etc… moves in air/wind direction?

An example of wind system I would like to achiave in Roblox.

Should I inject some sort of body movers? CFrame?

9 Likes

Depends on how your leaves and grass is made.

If they have collisions, you can use combinations of contraints with motors/servos or using BodyForce to provide the movement and use contraints to constrain it. Or use BodyForce or BodyPosition on their own. CFrame can be light weight and very controlled if you make various physics approximations and if the blown objects don’t have collisions. For certain things you could even use beams.

It really depends on your setup. Grass would probably be “hinged” around their root, so contraints or CFrame is required, things like flags could likely be done entirely different using beams.

There isn’t any single solution that should be used for every type of object. It’s up to you to pick the most appropriate.

How you choose to set up the script(s) is up to you, but I’d have a central function/loop that determines global wind speed and direction. Then I’d have a second loop that updates the various different blowable objects. To save processing, if the wind speed and direction hasn’t changed it could skip over things where the input wouldn’t change, like servos and BodyPosition, and just update any manual CFrame and BodyForces if necessary as those will likely need updating every frame or so. This way all of the updates read the speed and direction from the main loop and you just use if conditions to set your beams, bodymovers, CFrames, constraints etc.

Hopefully that gives you some ideas to start planning out the blowable objects and how they might feasibly move, whether they are pinned or are an encastré beam, etc.

4 Likes

I agree with most everything BanTech said in his post above, however using these can become very taxing on lower-end computers, so consider just using a loop of position tweening every x seconds, with this preferably being a setting you can toggle so that players with lower end pcs can still play your game. Doing this on the client would be preferred as that both saves server resources and reduces the amount of replication that’s needed, making it have lower network usage.

If you’re looking for something that moves when the player touches it, you’d likely want to use the same system but listen for character touched events and checking to see if the object that touched is a plant and tweening the plant accordingly.

4 Likes

This post will most likely be helpful to what your trying to do:

4 Likes

You need to be more specific. How is your grass created? Is it simply a single part that moves around? Are there multiple parts? Do you want to use ROBLOX physics or your own accurate implementation?

The best way I would do this is via a soft-body physical model for grass. You can do this with a series of point masses that are coupled via springs. This will allow you to model the particle-particle interactions for a grass blade. You can then use “Verlet Integration” to essentially simulate the Newtonian Physics ODE in ROBLOX. There are lots of tutorials on this website on this topic.

2 Likes

Grass is a single part, but trees are with multiple parts.

1 Like

Personaly, I will use animations

This might be overkill, but whatever solution you use to animate the branches, leaves etc.
You can get the wind direction in any given point by using math.noise.

https://gyazo.com/6184f612eeafcdfad6d2fb1eace3a439
https://gyazo.com/4263ca5f4702bf1efd649e3653ba9f20

I created a demo place here: SimulatedWind3D.rbxl (19.3 KB)

9 Likes

I am not very experienced in this but I agree with @PlaceRebuilder. And the video contains some not family friendly content. Please fix it.

:+1:

1 Like

Sorry, I made mistake I just looked at video and I know what you talking about, I posted because I wasn’t looking what was happening in background but rather at moving leaves and objects