Hi guys
I use windfield and I need two objects to pass through each other, so I made one object as sensor object using setSensor funcion but I found windfield doesn't detect sensor object collision!
I used collider:enter() in update function to detect collision but it doesn't work, I used preSolve call back method as well but still it doesn't detect any collision while one object is sensor!
How do you handle it using windfield? something simple like a character who should collect stars or food!
windfield doesn't detect sensor object collision?
Re: windfield doesn't detect sensor object collision?
I believe this should be posted under Support. Also windfield is 6 years old and even archived on Github, which is a good sign to never use it.Navid wrote: ↑Thu Jul 20, 2023 2:58 pm Hi guys
I use windfield and I need two objects to pass through each other, so I made one object as sensor object using setSensor funcion but I found windfield doesn't detect sensor object collision!
I used collider:enter() in update function to detect collision but it doesn't work, I used preSolve call back method as well but still it doesn't detect any collision while one object is sensor!
How do you handle it using windfield? something simple like a character who should collect stars or food!
You can try using breezefield instead: https://github.com/HDictus/breezefield
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: windfield doesn't detect sensor object collision?
Thanks dusoft, I try breezefield and sorry for wrong topic, I thought support section is just about Love itself!dusoft wrote: ↑Thu Jul 20, 2023 9:22 pm I believe this should be posted under Support. Also windfield is 6 years old and even archived on Github, which is a good sign to never use it.
You can try using breezefield instead: https://github.com/HDictus/breezefield
Re: windfield doesn't detect sensor object collision?
I was thinking the same way originally. Tried windfield, it didn't work, tried breezefield, it worked, but I liked HardonCollider more. That was old and has issues between different versions.Navid wrote: ↑Fri Jul 21, 2023 8:19 amThanks dusoft, I try breezefield and sorry for wrong topic, I thought support section is just about Love itself!dusoft wrote: ↑Thu Jul 20, 2023 9:22 pm I believe this should be posted under Support. Also windfield is 6 years old and even archived on Github, which is a good sign to never use it.
You can try using breezefield instead: https://github.com/HDictus/breezefield
However, in the end I just went the hard way and used raw love.physics class:
https://love2d.org/wiki/World:setCallbacks
My boat driving game demo: https://dusoft.itch.io/captain-bradley- ... itius-demo
Re: windfield doesn't detect sensor object collision?
Yes I agree, I was trying windfield as simple way in normal test project not commerical game, but I think it worth using love.physics itself on many serious projects.dusoft wrote: ↑Fri Jul 21, 2023 8:43 am
I was thinking the same way originally. Tried windfield, it didn't work, tried breezefield, it worked, but I liked HardonCollider more. That was old and has issues between different versions.
However, in the end I just went the hard way and used raw love.physics class:
https://love2d.org/wiki/World:setCallbacks
btw, is there any like button in this forum? or something like that to say thank you to people who help us? It's not cool to replay a post just to say thank you
-
- Prole
- Posts: 12
- Joined: Sat Oct 21, 2023 1:33 pm
Re: windfield doesn't detect sensor object collision?
Hey there before enter methodyou have add addtional code in windfield
(collected from windfield wiki)
function love.load()
world = wf.newWorld(0, 512, true)
world:addCollisionClass('Platform')
world:addCollisionClass('Player')
ground = world:newRectangleCollider(100, 500, 600, 50)
ground:setType('static')
platform = world:newRectangleCollider(350, 400, 100, 20)
platform:setType('static')
platform:setCollisionClass('Platform')
player = world:newRectangleCollider(390, 450, 20, 40)
player:setCollisionClass('Player')
-- extra code
player:setPreSolve(function(collider_1, collider_2, contact)
if collider_1.collision_class == 'Player' and collider_2.collision_class == 'Platform' then
local px, py = collider_1:getPosition()
local pw, ph = 20, 40
local tx, ty = collider_2:getPosition()
local tw, th = 100, 20
if py + ph/2 > ty - th/2 then contact:setEnabled(false) end
end
end)
end
function love.keypressed(key)
if key == 'space' then
player:applyLinearImpulse(0, -1000)
end
end
(collected from windfield wiki)
function love.load()
world = wf.newWorld(0, 512, true)
world:addCollisionClass('Platform')
world:addCollisionClass('Player')
ground = world:newRectangleCollider(100, 500, 600, 50)
ground:setType('static')
platform = world:newRectangleCollider(350, 400, 100, 20)
platform:setType('static')
platform:setCollisionClass('Platform')
player = world:newRectangleCollider(390, 450, 20, 40)
player:setCollisionClass('Player')
-- extra code
player:setPreSolve(function(collider_1, collider_2, contact)
if collider_1.collision_class == 'Player' and collider_2.collision_class == 'Platform' then
local px, py = collider_1:getPosition()
local pw, ph = 20, 40
local tx, ty = collider_2:getPosition()
local tw, th = 100, 20
if py + ph/2 > ty - th/2 then contact:setEnabled(false) end
end
end)
end
function love.keypressed(key)
if key == 'space' then
player:applyLinearImpulse(0, -1000)
end
end
Who is online
Users browsing this forum: No registered users and 1 guest