I will make a game platform, how to make opponents can detect the position of player who approached him (opponent)
i use the following method for player
and, this method for enemy
But, the enemy cant get nearest position of player
for illustration like this
Thankyouu
public int getnilaiX() { return getX(); } public int getnilaiY() { return getY(); }
public void cekPlayer() { int x = ((player) getWorld().getObjects(player.class).get(0)).getnilaiX(); int y = ((player) getWorld().getObjects(player.class).get(0)).getnilaiY(); if (y <getY()+2 && y > getY()-2 && jumping == false) { jump(); } }