[Resolved] Fans strength

Hi everyone.

I am creating a fan to push some water and other things, and i was seeing the best solution to do it.
I saw applyForce, applyLinearImpulse, and not too much ways, i saw on some games that on the fans, per exemple if the water collides close of the fan it have more strength and if the water collides at the end of the of the fan, normally on the end of the particles exhausted by the fan, the strength of the fan is lower, it is equal on the real life.
I dont know if exist some ways to help to create this effect, because with applyForce i am no getting the best results, can anyone tell me your experience with this problem or give me some tips and opinions to build a good fan?

Thanks community [import]uid: 26056 topic_id: 23939 reply_id: 323939[/import]

[lua]require ( “physics” )
physics.start()
physics.setGravity( 0, 7 )

local fan = display.newRect( 10, 200, 30, 150 )
physics.addBody(fan, “static”)

local ground = display.newRect( 0, 350, 320, 20 )
ground:setFillColor(150, 100, 0)
physics.addBody(ground, “static”)

local fanSensor = display.newRect( 10, 200, 310, 100 )
fanSensor.alpha = 0.2
physics.addBody(fanSensor, “static”, {isSensor=true})

local rain = {}

local function spawnRain()
rain[#rain+1]=display.newCircle( math.random(40,280), 0, 10 )
physics.addBody(rain[#rain])
rain[#rain].name = “rain”
end
timer.performWithDelay(100, spawnRain, 10)

local function hitFan(event)
if event.other.name == “rain” then
fanDist = (event.other.x-fan.x) / 100
print (fanDist)
event.other:applyForce(fanDist, 0)
end
end
fanSensor:addEventListener(“collision”, hitFan)[/lua]

That is incredibly rough and I haven’t actually tested it, so no guarantees on it working - but it should give you something to go on at the very least. (I set the sensor to show with a low alpha but you could make it invisible.)

Peach :slight_smile: [import]uid: 52491 topic_id: 23939 reply_id: 96510[/import]

Hi peach, it is a great help for me, thank you very much for this, i will try to improve this fan. Thanks again :slight_smile: [import]uid: 26056 topic_id: 23939 reply_id: 96545[/import]

Great, glad to hear that - good luck with your project, I hope with a little tweaking you can get it working how you want it :slight_smile: [import]uid: 52491 topic_id: 23939 reply_id: 96804[/import]