Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About gmfreaky

  • Rank
  1. gmfreaky

    AABB Collision problems

    I think I have found out why it doesn't work: I sort my entities on distance to camera. When I place a line of colliding blocks, I see that always the furthest away block doesn't detect collision. However, I haven't got a clue on how to solve it... any idea's? EDIT: I solved the problem: the problem was that some entities were getting updated before other entities, and the entitylist wasn't complete yet.
  2. gmfreaky

    AABB Collision problems

    I made a video showing the problem. Watch it here: [media][/media]
  3. gmfreaky

    AABB Collision problems

    @Wildbunny thank you for your code. It works a bit better now, but there is still glitches going on. Sometimes it doesnt detect correctly, kind of like the previous bug, but a bit different. It also seems to have to do with the Z of objects. New code: public boolean isColliding(AABB a, float xo, float yo, float zo) // Return if this AABB is colliding with another AABB { float Dx = Math.abs((x+xo)-a.x) - ((rxsize/2)+(a.rxsize/2)); float Dy = Math.abs((y+yo)-a.y) - ((rysize/2)+(a.rysize/2)); float Dz = Math.abs((z+zo)-a.z) - ((rzsize/2)+(a.rzsize/2)); return (Dx < 0 && Dy < 0 && Dz<0); } So the problem is similar, just different. @Ashaman73: I want the player to be able to still move if they hit something, and not freeze.
  4. gmfreaky

    AABB Collision problems

    I made an image describing the problem briefly It's in top-view:
  5. gmfreaky

    AABB Collision problems

    Hello, I'm new to this forum, so don't be too hard on me (also I'm from the Netherlands, so my English probably sucks.) I am developing a little game in Java, using the lwjgl-library and slick. I've come quite far, but I have some problem with my collision detection. For collision detection I use simple Axis Aligned Bounding Boxes. I have a class called Entity, and a class called PhysicsEntity which extends on Entity, and contains some information like xspeed, yspeed, zspeed, and more. The PhysicsEntity class also has an variable called aabb, of type AABB (a class which contains xsize, ysize, zsize, position, rotation, and more information) Every update cycle the PhysicsEntity class calls a function named 'tryMove();' which handles movements. This has the following in it: public void tryMove() { PhysicsEntity xe = w.getCollidingEntity(aabb, xspeed,0,0); PhysicsEntity ye = w.getCollidingEntity(aabb, 0,yspeed,0); PhysicsEntity ze = w.getCollidingEntity(aabb, 0,0,zspeed); if (xe==null){x+=xspeed;}else{xspeed=0; onCollide(xe);} if (ye==null){y+=yspeed;}else{yspeed=0; onCollide(ye);} if (ze==null){z+=zspeed;}else{zspeed=0; onCollide(ze);} } What it does is: - Get the entity which it collides with on all the axis+speed. - Check if it is not occupied, then add speed on that axis. In World.getCollidingEntity it says this: public PhysicsEntity getCollidingEntity(AABB aabb, float xo, float yo, float zo) { for(PhysicsEntity e:activePhysicsList) { if(aabb!=e.aabb && aabb.isColliding(e.aabb, xo, yo, zo)) { return e; } } return null; } In the AABB class it says this: public boolean isColliding(AABB a, float xo, float yo, float zo) // Return if this AABB is colliding with another AABB { float x1 = x-(rxsize/2)+xo; float y1 = y-(rysize/2)+yo; float z1 = z-(rzsize/2)+zo; float x2 = x+(rxsize/2)+xo; float y2 = y+(rysize/2)+yo; float z2 = z+(rzsize/2)+zo; float ax1 = a.x-(a.rxsize/2); float ay1 = a.y-(a.rysize/2); float az1 = a.z-(a.rzsize/2); float ax2 = a.x+(a.rxsize/2); float ay2 = a.y+(a.rysize/2); float az2 = a.z+(a.rzsize/2); return( (x1 < ax2 && x2 > ax1) && (y1 < ay2 && y2 > ay1) && (z1 < az2 && z2 > az1)); } Now the problem is: from one side (negative x,y,z) this all works quite well, but when the X Y or Z is larger than the others X Y Z, things are getting buggy. Could you maybe help with this problem? Here is a test-version of the game: Download This is copyrighted content, please do NOT use any of this in your projects. All other Entities have been disabled. Controls for the test: WASD for movement Space for jumping F for spawning a test box Numpad + for changing time Thanks for taking your time for reading this post you must be very patient. I hope you can help me, thanks in advance, Robin. P.S. I can PM you the full source if you need more information.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!