When I jump on platforms, I fall straight through after a few seconds. Also, I am able to jump through the bottom of the platform and land on top (this is also not intended) Does anyone have any idea how to fix this?
Here is my code:
Surface = Level of the ground
CheckContact1, 2 and 3 = For platforms 1, 2 & 3 respectfully. (Different sprites for each level)
private void checkContact(){
Actor checkContact = getOneIntersectingObject(Level1Platform.class);
Actor checkContact2 = getOneIntersectingObject(Level2Platform.class);
Actor checkContact3 = getOneIntersectingObject(Level3Platform.class);
if(checkContact !=null){
int checkContactY = checkContact.getY();
if(getY()>(checkContactY)){
Surface = (checkContactY-50);
setLocation(getX(), Surface);
//This will keep R2D2 on the platform and display a message when a collsion occurs
}
if(RLspeed < 0){
Surface = 366;
setLocation(getX(), Surface);
}
}else{
Surface = 366;
}
if(checkContact2 !=null){
int checkContactY = checkContact2.getY();
if(getY()>(checkContactY)){
Surface = (checkContactY-30);
setLocation(getX(), Surface);
//This will keep R2D2 on the platform and display a message when a collsion occurs
}
if(RLspeed < 0){
Surface = 366;
setLocation(getX(), Surface);
}
}else{
Surface = 366;
}
if(checkContact3 !=null){
int checkContactY = checkContact3.getY();
if(getY()>(checkContactY)){
Surface = (checkContactY-30);
setLocation(getX(), Surface);
//This will keep R2D2 on the platform and display a message when a collsion occurs
}
if(RLspeed < 0){
Surface = 366;
setLocation(getX(), Surface);
}
}else{
Surface = 366;
}
}
