• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

104 Neutral

About regenschauer

  • Rank
  1. Collision Correction

    Dear Community; I have a Problem with the Correction after a Collision in a Platformer I try to create. I have tried many things and all have magically failed. Now, I turn to you, as I feel like I might need some external help with the Problem.   I use Java and I have a Entity class, which has a function called collide with a list of other Game Objects. If I find a Collision, I add it to an Array of colliding objects. Now, I would need to work out how to move the this object out all those collisions.   My coordinate System is also oriented with the y axis pointing downwards, meaning the bigger the y value, the lower the object on the screen.   Objects are represented like this:   And the Objects I collide are determined like this. public void collide(ArrayList<Entity> objectsToCollide){ ArrayList<Entity> CorrectionEntities = new ArrayList<Entity>(); for(int i = 0; i < objectsToCollide.size(); i++){ Entity currentCollisionObject = objectsToCollide.get(i); if(currentCollisionObject == this) continue; if(Entity.entityBoxesIntersect(this, currentCollisionObject)){ CorrectionEntities.add(currentCollisionObject); } } if(CorrectionEntities.size() == 0) return; for(int i = 0; i < CorrectionEntities.size(); i++){ //TODO: Correct Position } }   Now the correction is supposed to happenn at the TODO marking, I put it there, as the other trials have failed horribly.   Thank you very much for your help,   regenschauer
  • Advertisement