I want to make AI that can follow the motion of the player. like if the player jumped he jumped too.
The actor that follows the motion of the player will probably need not only a reference to that player, but also its last known location coordinates:
Actor player;
int playerX, playerY;
There are multiple ways to get the reference to assign to the Actor field (passing it in a parameter of the constructor or another method; or by getting it from a generated list of player objects in the world either in the act or addedToWorld method). Then, after comparing the current location with last known location, move AI actor and save new coordinates.
I want to make AI that can follow the motion of the player. like if the player jumped he jumped too.
The actor that follows the motion of the player will probably need not only a reference to that player, but also its last known location coordinates:
Actor player;
int playerX, playerY;
There are multiple ways to get the reference to assign to the Actor field (passing it in a parameter of the constructor or another method; or by getting it from a generated list of player objects in the world either in the act or addedToWorld method). Then, after comparing the current location with last known location, move AI actor and save new coordinates.
emm can you explain me an example of the method code used?