how to detect if a collider is tuching a nothere collider in the physics system in love2d
Posted: Sat Feb 18, 2023 2:47 am
I need help
when I use enemy.hitbox:isTuching(player.hitbox)Andlac028 wrote: ↑Sat Feb 18, 2023 5:50 am Try to look at Body:isTouching or World:getContacts if you use love. physics.
I don’t know, what player.hitbox is, but you should pass body as argument, not table. Just find, where you save player body during creation of player (love.physics.newBody()) and use it as argument instread of player.hitbox.A-lox wrote: ↑Sat Feb 18, 2023 2:44 pmwhen I use enemy.hitbox:isTuching(player.hitbox)Andlac028 wrote: ↑Sat Feb 18, 2023 5:50 am Try to look at Body:isTouching or World:getContacts if you use love. physics.
then it gives me this error:
Error: main.lua:193: bad argument #1 to 'isTouching' (Body expected, got table)
stack traceback:
[love "boot.lua"]:345: in function <[love "boot.lua"]:341>
[C]: in function 'isTouching'
main.lua:193: in function 'enemy_del'
main.lua:50: in function 'update'
[love "callbacks.lua"]:162: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'
It simply means that the value you give as parameter of :isTouching is not a Body "object" but a table.A-lox wrote: ↑Sat Feb 18, 2023 2:44 pmwhen I use enemy.hitbox:isTuching(player.hitbox)Andlac028 wrote: ↑Sat Feb 18, 2023 5:50 am Try to look at Body:isTouching or World:getContacts if you use love. physics.
then it gives me this error:
Error: main.lua:193: bad argument #1 to 'isTouching' (Body expected, got table)
stack traceback:
[love "boot.lua"]:345: in function <[love "boot.lua"]:341>
[C]: in function 'isTouching'
main.lua:193: in function 'enemy_del'
main.lua:50: in function 'update'
[love "callbacks.lua"]:162: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'