Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am making a game in Unity. I have an object e.g. cube. I want to release air from it like fan so that when other cubes come closer, it throws them away. What velocity,force etc I will need to do that?

share|improve this question

migrated from physics.stackexchange.com May 21 '13 at 8:04

This question came from our site for active researchers, academics and students of physics.

    
The solution to this might be in the following link. answers.unity3d.com/questions/31872/… –  Mikolaj Marcisz May 21 '13 at 9:50
add comment

2 Answers 2

up vote 9 down vote accepted

While the aerodynamic effects caused by a fan can be quite complex to model accurately, it is sufficient for most cases to model the force it applies after the Inverse-Square Law.

It means that the force it applies to another object is divided by the distance multiplied with itself.

Another factor you could or could not model depending on how physically correct you want to be is the wind drag of the objects which are pushed by the fan. Wind drag means that objects with a large surface exposed to the wind direction receive more force from the wind than those with a smaller surface (again, overly simplified. The aerodynamics are a lot more complex in reality). When you want to model this, you also need to multiply the force with the surface area of the object which is pushed.

The complete formula would then be:

appliedForce = fanForce / (distance * distance) * surfaceArea

There is, however, a pitfall in this formula: it has a singularity when the distance is 0. When the distance is below 1, the force will be more than the intended maximum. When the distance gets very small, the force can become extremely strong. This could lead to quite glitchy behavior. To fix this issue, add 1 to your distance calculation, or cap the distance at 1:

appliedForce = fanForce / (1.0 + distance * distance) * surfaceArea

or

if (distance < 1.0) distance = 1.0;
appliedForce = fanForce / (1 + distance * distance) * surfaceArea;    

More accurate results could be reached by an actual physical simulation of aerodynamics, but this is a highly complex field, both in regards to development time and computational resources. Unless physically accurate aerodynamics are a core gameplay-element of your game, it is unlikely to be worth the hassle.

share|improve this answer
    
I don't understand why you would divide by the surface area, shouldn't you be multiplying by it? –  Joren May 21 '13 at 15:31
    
@Joren I am multiplying by the surface area. In most programming languages there is no operator precedence between division and multiplication, so they are executed in the order they are written in. –  Philipp May 21 '13 at 19:33
add comment

You could simply calculate the distance ( you can use any mesh for collision clipping to represent the "air flow" limits), the closer it gets the higher the force you apply to it in that direction. Of course this isn't as accurate, but you could add noise to the direction of the velocity.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.