Hello,
can anyone point me to a good lib for simulating liquid, but top down? I have checked the wiki, there are some outdated libs that even throw 404s. I have checked the awesome love2d list, but that does not really have this kind of physics.
Also, I need to work with polygons (probably going to use either older v of HardonCollider or Strike lib, both work well), but I still need help with physics.
Basically I just need to simulate very simple physics for entities moving in water (such as boats etc.).
(PS: I know can probably simulate this via love.physics, but then I would start from the beginning. If there was an existing library, I would prefer using that.)
UPDATE: I am trying to use love.physics and got some primitive concepts working. I do not understand what I should do regarding angles. E.g. boat is always moving to front (if LinearVelocity goes negative). But front means different directions based on different angle. So how do I calculate LinearVelocity X,Y based on this angle? If I don't do it, such boat will always just move up (negative LinearVelocity y), even if it faces down (e.g. decimal angle 180).
Top-down liquid (water) physics simulation
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Top-down liquid (water) physics simulation
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Top-down liquid (water) physics simulation
Unless I'm misunderstanding something:
Code: Select all
body:setLinearVelocity(math.cos(angle)*speed, math.sin(angle)*speed)
Re: Top-down liquid (water) physics simulation
pgimeno wrote: ↑Tue Apr 04, 2023 5:46 pmUnless I'm misunderstanding something:
Code: Select all
body:setLinearVelocity(math.cos(angle)*speed, math.sin(angle)*speed)
I would prefer using body:applyForce(xf, yf) instead as setting Velocity directly defeats the purpose, but I guess I could work with this. Thanks!
Last edited by dusoft on Tue Apr 04, 2023 6:01 pm, edited 1 time in total.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Top-down liquid (water) physics simulation
Hard to give any further advice without any code to look at, sorry.
Re: Top-down liquid (water) physics simulation
Are you need the physics of hovercraft? It goes not where it's directed, but where it has the speed as rest on inertia.
Re: Top-down liquid (water) physics simulation
No, I would like to use body:applyForce for speeding up a boat. E.g. holding up key applies force continuously by the physics class of LOVE. I am now a bit stuck how to represent this using this function.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Top-down liquid (water) physics simulation
Use the same principle.
You have a vector expressed as the boat's direction and the boat's speed.
You want to express the vector as two linear components.
To do this you use sin and cos.
This will not give you boat physics more spaceship physics but you can tweak it from there.
For example adding friction and maybe the ship's rudder should only turn the boat when it is moving forward etc
You have a vector expressed as the boat's direction and the boat's speed.
You want to express the vector as two linear components.
To do this you use sin and cos.
Code: Select all
body:applyForce(math.cos(angle)*speed, math.sin(angle)*speed)
For example adding friction and maybe the ship's rudder should only turn the boat when it is moving forward etc
Re: Top-down liquid (water) physics simulation
OK, I am going to try that. I though I wouldn't have to keep speed variable manually as the physics module takes care of that (getLinearVelocity), but alright. Regarding friction - I have already solved this by damping.knorke wrote: ↑Thu Apr 06, 2023 12:11 am Use the same principle.
You have a vector expressed as the boat's direction and the boat's speed.
You want to express the vector as two linear components.
To do this you use sin and cos.
This will not give you boat physics more spaceship physics but you can tweak it from there.Code: Select all
body:applyForce(math.cos(angle)*speed, math.sin(angle)*speed)
For example adding friction and maybe the ship's rudder should only turn the boat when it is moving forward etc
On an unrelated note: I really think the physics module should be simplified, all these concepts (separate body, shape etc.) are hard to grasp first even for a programmer with 25+ years of experience (not in games, though). I am getting through, though.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: Top-down liquid (water) physics simulation
ah, "speed" is just bad naming because I copypasted.
It is actually a constant, a better name would be "thrustPower".
It is actually a constant, a better name would be "thrustPower".
Re: Top-down liquid (water) physics simulation
Well noted and makes more sense.
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Who is online
Users browsing this forum: Google [Bot] and 4 guests