Justin Hur
Game Programmer
Documentation
Objective:
Teleporting enemy is like the other enemies affected by time. They can be slowed by the player and can be damaged regardless of time being stopped. They will also teleport after attacking the player with a range attack. If the player slows time while they are teleporting the player can catch them mid teleport to kill them.
​
Process:
I went ahead and copied some of the code from the Sentiel script and placed it on the Teleporter script for shooting 4 projectiles. Then created a Teleporting State, this is for when the enemy is actually in motion; Setting State, this is for when the enemy is calculating the navmesh path to randomize location; and then attacking state, this is for the actual firing of the projectiles.
​
I found the same issues I was having with gargoyle where if I made the enemy too fast, and using the agent.setdestination method, then the ai will overshoot its destination. So I reused the navmeshpath calculation scripted used for the Gargoyle and copied to the Teleporter script.
​
For picking a randomized spot, I used the Random.insideUnitSphere keywords to calculate a randomized location. Then I used NavMesh.SamplePosition of that randomized location to see if that location is somewhere on that navmesh. If so, then the AI will calculate a path to that navmesh, then I would make the enemy move to the specific vector positions of that path.
​
If I let the AI run, it will randomly move to its location in high speeds, but it moves so fast without a restrictor that it's makes the fight much more difficult. So I set a cooldown timer of 1.25f so that the enemy will stay in position for that long then fire, then move to a new location. Repeat. This gives the player enough time to move around while also having a harder time trying to hit the enemy if time is not stopped.
​
For the timestop, I made it so that the enemy is at 100f maxspeed and 8f minspeed. So when the time is stopped, the enemy will move at minspeed, and when time runs normally, they'll go maxspeed.
​
The final problem I had is that sometimes the enemy will run into the player causing the player to take damage. This is not what is intended, so I made a collision modifier that turns off the collider if time is not stopped and the enemy is in the teleporting state. Otherwise, the collider remains active.