so here i have my first NPC for the game. it is meant to roam a small area until the player enters a certain range, upon which it should track the player and interact in some way, but that is not the topic of this post. i realise that using rotation would be quite easy in this case, but ive tested it and it looks quite weird in my opinion.. heres the code:
the movement would go into the if condition within public void roam(). i have tried using random numbers in conjunction with the setlocation method, but it didnt work very well....
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
public class NPC extends Actor
{
PC player;
public void act()
{
roam();//randomly patrol a defined area around this object
trackPlayer();//track the player as soon as they enter a certain AOE, increase speed
}
public NPC(PC player){
this.player = player;
}
public void roam(){
if(getObjectsInRange(250, PC.class).isEmpty()){
}
}
public void trackPlayer(){
}
}
