how to detect if a collider is tuching a nothere collider in the physics system in love2d
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: how to detect if a collider is tuching a nothere collider in the physics system in love2d
Try to look at Body:isTouching or World:getContacts if you use love.physics.
Re: how to detect if a collider is tuching a nothere collider in the physics system in love2d
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.
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'
Re: how to detect if a collider is tuching a nothere collider in the physics system in love2d
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'
If you need help with this please share your code or some reproducible example (or if it is problem to post it publically, PM it to me so I can help you (I will delete the copy of it after problem is solved))
Last edited by Andlac028 on Sat Feb 18, 2023 3:52 pm, edited 1 time in total.
Re: how to detect if a collider is tuching a nothere collider in the physics system in love2d
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'
What does the "hitbox" value represent? Do you use a physics library such as windfield or other?
Share your code with us, it will be easier to help you
Who is online
Users browsing this forum: Semrush [Bot] and 1 guest