Page 1 of 1
How would i detect collison between a player and object using box2d
Posted: Sat Apr 29, 2023 1:29 am
by l0ki77
Hello I am currently making a game for my class and I was wondering how I would detect Collison between a Player and object using box2d. I would also wondering how you could spawn the object that the player collided with in a random location on the tiled map through the lenses of a camera.
Re: How would i detect collison between a player and object using box2d
Posted: Sat Apr 29, 2023 6:45 am
by darkfrei
l0ki77 wrote: ↑Sat Apr 29, 2023 1:29 am
Hello I am currently making a game for my class and I was wondering how I would detect Collison between a Player and object using box2d. I would also wondering how you could spawn the object that the player collided with in a random location on the tiled map through the lenses of a camera.
Just from documentation:
Code: Select all
if playerFixture:isTouching(objectFixture) then
https://love2d.org/wiki/Body:isTouching
or
https://love2d.org/wiki/World:queryBoundingBox
Re: How would i detect collison between a player and object using box2d
Posted: Sat Apr 29, 2023 9:22 am
by dusoft
Use contacts:
https://love2d.org/wiki/Contact
Specifically create callbacks:
https://love2d.org/wiki/World:setCallbacks
I *would not* recommend using functions mentioned above as the documentation states they are not recommended and might miss collisions.