leaves falling from the tree and physically

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
soullessbr
Prole
Posts: 11
Joined: Sat Jun 01, 2013 1:18 am

leaves falling from the tree and physically

Post by soullessbr »

Hello everyone, okay?

I have no idea how I can get this effect leaves falling from the tree and physically rough terrain like in the video below. Could anyone give me some tips?

http://www.youtube.com/watch?v=bNmBGXaURx4

Thank you.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: leaves falling from the tree and physically

Post by micha »

The leaves are subject to gravity and strong air resistance.

The first thing is to implement gravity. That means that each leaf needs a velocity vector and gravity acts on it as an acceleration. Have you done this before? Otherwise, please ask.

The second thing is to implement air resistance. The equation that describes this is the drag equation. The factors rho, C_d and A are irrelevant here, because you only want it to look good (not necessarily to be physically exact). Just pick a fixed number for all these factors. In short: First calculate the relative velocity, that is the difference between the background velocity (wind) and the velocity of the leaf. Square this velocity and multiply it by the normalized vector that points in the opposite direction of the relative velocity. Last multiply this by a constant that you find by experimentation (until it looks good). The result is an acceleration vector that you let act on the leaf's velocity.

Edit: To get a more irregular behavior, you also have to add a bit of randomness. Ad hoc, I don't know how to do this in a reasonable way.
soullessbr
Prole
Posts: 11
Joined: Sat Jun 01, 2013 1:18 am

Re: leaves falling from the tree and physically

Post by soullessbr »

First, thanks for the reply.

To be honest never shifted with games so I'm picking up a bit, but walking. I'm at work right now (I'm php developer) and when I get home I'll try to implement something.

Thank you in advance partner!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 1 guest