This site requires JavaScript, please enable it in your browser!
Greenfoot back
Facehugger
Facehugger wrote ...

2018/8/4

Greenfoot isTouching() issues

Facehugger Facehugger

2018/8/4

#
When I use the isTouching() method in to make collisions my character floats 50 px from object. This doesn't occur when using !=null, but there are some issues with the character floating through walls.
public void PlatformCollisions(){
        Actor Platform;
        Platform = getOneObjectAtOffset(0 ,0, Platform.class);
        if(isTouching(Platform.class)){
            setLocation(getX(),getY()-4);
            Global.ground=true;
           
        }
    }
Super_Hippo Super_Hippo

2018/8/4

#
isTouching(Platform.class) is the same as doing getOneIntersectingObject(Platform.class) != null, but it is not the same as doing getOneObjectAtOffset(0, 0, Platform.class) != null. It is a different method which behaves differently.
Facehugger Facehugger

2018/8/5

#
Thank you for the clarification, it help me figure it out.
You need to login to post a reply.