Jump to content
  • Advertisement
Sign in to follow this  
Bonechilla

2D Collision

This topic is 2898 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am planning a 2.5D sidescroller in java that uses 3D models. Since thier are generally only 2 dimensions at a given time i've decided to take hold of java's awt library and use rectangle collision. So far I have gotten the models to correctly fall onto the floor however i seem to be having issues when they fall on top of each other. I created a hashmap with the characters spatials as keys and the awt rectangle as the entry.

Are their any suggestions on what should actually happen when a character lands ontop of another i was thinking they would slide off but everything i have tried until now have caused issues


for(int x=0; x<updateSpeed;x++){
for(Spatial s: models.keySet()){
updateModelCollision(s);
boolean onGround = true;
for(Spatial p: platforms.keySet()){
if(!models.get(s).intersects(platforms.get(p))){
onGround=false;
s.move(0,-1f*tpf,0);
}
}
for(Spatial s2: models.keySet()){
if(!s.equals(s2)&&models.get(s).intersects(models.get(s2))){
if(onGround==false)
System.out.println("something should happen when two characters bump");
}
}
}
}

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!