ContactList Normals, Definitive noob friendly advice?

Topics: Project Management Forum, User Forum
Feb 13, 2010 at 5:01 PM

Hi there,

I'm currently working on the University project in which we have to team up with a design 'team' and create a 10 level platform game.

Now I have the basis of the engine working, although their are some flaws. Currently my collision detection is as follows:

 

public bool OnCollision(Geom g1, Geom g2, ContactList contactList)
{
 return IsonGround = true;
}
public void OnSeparation(Geom g1, Geom g2)
{
IsonGround = false;
 }

//Within the Update method

if (IsonGround == true && s.IsKeyDown(Keys.W))
circleSprite.Body.ApplyImpulse(new Vector2(0.0f, -100f));


This creates a realistic jump with regards to gravity enabled.

The players collision at his feet will enable him to jump once more, but all of the sides of the player can cause the collision.

The Issue I am having is that if the sprite (being a rectangle) hits the side of a wall, the collision is True and he will beable to wall run(not a skill I wish my young pixel to have).

Could someone please post some example code and explain how to manipulate certain sides of the rectangle, I have looked over a few other topics and they explain the principle but I cannot produce practical code for it to be effective.

Thank you very much.

 

Feb 27, 2010 at 8:26 PM

I am a relative newbie with Farseer. But I would think that you might need a second geom. Use a geom that is for the feet or lower portion of the sprite geom. This way you can test it for collision instead of the geom that bounds the whole sprite. This is only if I understand the question right.