windfield doesn't detect sensor object collision?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Navid
Prole
Posts: 3
Joined: Thu Mar 09, 2023 3:14 pm

windfield doesn't detect sensor object collision?

Post by Navid »

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!
User avatar
dusoft
Party member
Posts: 629
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: windfield doesn't detect sensor object collision?

Post by dusoft »

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!
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
Navid
Prole
Posts: 3
Joined: Thu Mar 09, 2023 3:14 pm

Re: windfield doesn't detect sensor object collision?

Post by Navid »

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
Thanks dusoft, I try breezefield and sorry for wrong topic, I thought support section is just about Love itself! ;)
User avatar
dusoft
Party member
Posts: 629
Joined: Fri Nov 08, 2013 12:07 am
Location: Europe usually
Contact:

Re: windfield doesn't detect sensor object collision?

Post by dusoft »

Navid wrote: Fri Jul 21, 2023 8:19 am
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
Thanks dusoft, I try breezefield and sorry for wrong topic, I thought support section is just about Love itself! ;)
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
Navid
Prole
Posts: 3
Joined: Thu Mar 09, 2023 3:14 pm

Re: windfield doesn't detect sensor object collision?

Post by Navid »

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
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.
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 :awesome:
Tonmoy Mojumder
Prole
Posts: 12
Joined: Sat Oct 21, 2023 1:33 pm

Re: windfield doesn't detect sensor object collision?

Post by Tonmoy Mojumder »

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
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest