Notifications
Article
Enemy Radar Tutorial
Published 6 months ago
122
10
Enemy Radar Tutorial
Hey guys! I recently published a small tutorial on how to create an Enemy Radar screen over here: https://timcoster.com/2020/03/25/unity-enemy-radar-tutorial
In the tutorial you'll learn how to create a radar screen on a UI Canvas that can display the relative positions to the player of different entities or objects with different colors. You will also learn how to create a small testing environment for the radar, with random walking Enemy and NPC placeholders by using Unity's Navigation system.
Feel free to have a look. And of course I'd love to know what you think!
Cheers! Tim
Tim Coster
Indie developer/artist - Other
4
Comments
WW
Wendy Willid
3 months ago
super cool-some real talent here
0
Tim Coster
6 months ago
Indie developer/artist
Nicholas SevillaNever mind. This works perfectly now. I just had to add a few more enemies and npcs in the scene to make sure it worked. Thanks so much for this tutorial!!!
Great! I'm glad you got it to work:) The random walker script and radar script don't deal with spawning the enemies or NPC's at random but you could create a separate script for that and attach it to an empty GameObject in the center of the scene. If you name the script RandomEnemySpawner.cs and paste the code from below into it then you have a start, but it would be an entire separate tutorial to probably get it to do all the things that you want..Maybe search for a Unity enemy wave spawner tutorial online..:) Cheers! using System.Collections; using System.Collections.Generic; using UnityEngine; public class RandomEnemySpawner : MonoBehaviour { public GameObject enemyPrefab; public float spawnRadius = 20f; public float minSpawnInterval = 5.0f; public float maxSpawnInterval = 10.0f; public bool repeat = true; private float randomSeconds; private Vector2 randomPos; void Start() { StartCoroutine( SpawnEnemy() ); } IEnumerator SpawnEnemy() { randomSeconds = Random.Range(minSpawnInterval,maxSpawnInterval); randomPos = Random.insideUnitCircle * spawnRadius; yield return new WaitForSeconds(randomSeconds);
Instantiate(enemyPrefab,transform.position + new Vector3(randomPos.x,0,randomPos.y),Quaternion.identity);
if (repeat) { StartCoroutine( SpawnEnemy() ); } } }
1
Nicholas Sevilla
6 months ago
Frustrated
Nicholas SevillaProgress: I forgot to add tags for the blips, and the enemy and npc objects. now, to get it to spawn random ones, as I only see the ones in the scene. Yay!
Never mind. This works perfectly now. I just had to add a few more enemies and npcs in the scene to make sure it worked. Thanks so much for this tutorial!!!
0
Nicholas Sevilla
6 months ago
Frustrated
Nicholas SevillaI am following your tutorial, using Unity 2018.4... the npc and enemy capsules are not walking around. Will try to sort this out. Thanks.
Progress: I forgot to add tags for the blips, and the enemy and npc objects. now, to get it to spawn random ones, as I only see the ones in the scene. Yay!
0
Nicholas Sevilla
6 months ago
Frustrated
Nicholas SevillaI almost finished the tutorial: The script does not create enemies nor npcs... and if I do have some instantiated, they also do not show up on the radar.
Thanks. I am almost there, now I am not seeing any enemies spawn, and the two I have in the scene also do not show up in the radar. I did create prefabs for the Enemy and the NPC capsule objects. Which is also not mentioned in the tutorial.
0