Last Seen With the Ray Sensor

I have a ray sensor set up to an enemy AI in my game, and whenever it sees the player it switches its state to where it always follows the player via a steering actuator. But, what I want to try to do is to make it so that the instant the enemy ray stops hitting the player it creates a way-point (or an object) for the enemy to move to instead of the player, and delete the way-point once the enemy reaches it.
Is there anyway to do this?
ps- I don’t really know python that well, but I will use it if it’s easier.
pps- Does anyone know how to make a ray track an object (such as the player or way-point)?

Ask if you need anymore details

I would place an object (e.g. an empty) at the identified position and navigate to the that object (rather than the player).

Yes you need python to read the sensor results and set the position of an object.

Thanks, but may I have an example of a script that I could use? And also, is there a way to make it so that the empty gets deleted once the enemy’s ray sees the player again or it reaches the empty?
Ps- If you do include the script, I would attach it to the object with the ray sensor, right?