Compound players with multiple bodies/fixtures?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
danielhilst
Prole
Posts: 2
Joined: Mon Aug 20, 2012 6:27 pm

Compound players with multiple bodies/fixtures?

Post by danielhilst »

Hi guys.. I'm studying collisions with physics engine.. I have created a "player" who I can move
left, right and jump, the player is a simple square body. Now, I want to be able to know what part
of my player is colliding when a collision is detected.. so, if the bottom part of my player is colliding
this means that he is on top of something.. I want it to jump only if is on top of something..

There are two ways,
1.- I can check the direction of the colision, geting the edges where the colision happen. So if a collision happens
on bottom part I know that my player is on top of something

2.- I can create a compound body, with multiple fixtures.. for example, one for foot, one for head, and one for body..
If i detect a collision on foot I know that I'm on top of something..

I have no idea of how to do any of this things, I guess collision object can give-me 1..For 2.. I know how to create multiple fixtures,
the problem is how to tie they together in an elegant way.

Any idea?

I will post the code I have .... just let me get to another computer where it is ...

Thanks!
Last edited by danielhilst on Tue Aug 21, 2012 2:16 pm, edited 1 time in total.
danielhilst
Prole
Posts: 2
Joined: Mon Aug 20, 2012 6:27 pm

Re: Compound players with multiple bodies/fixtures?

Post by danielhilst »

And here is the code! http://pastebin.com/nHcVx6Ay

and here is the .love file
square.love
Test collision
(1007 Bytes) Downloaded 260 times

-- Editing --
I thinkg Contact:getNormal() is what I want.. for 1

Anyone knows how to use??
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests