I am trying to access a health variable from my Tank.class and change it when the Tank gets hit with an Arrow. Here is the code:
It is on line 5 where the error is occurring. I did have it working by using getOneIntersectingObject in the if statement, but it was detecting a hit before it had actually hit the Tank since the image had empty space around the Tank. Thanks in advance!
public void hit()
{
Tank tank = (Tank)getOneIntersectingObject(Tank.class);
if(getOneObjectAtOffset(0, 0, Tank.class) == tank) {
tank.health = tank.health - 1;
getWorld().removeObject(this);
}
}

