Week 4 - Navigation
Using the terrain I created last week, I created a NavMesh, which provides a traversable environment for objects within the game that are NavMesh agents:
For the portfolio exercise, I first added a moving object to the scene. To do this, I created a simple 3D game object into the scene. I then created a script that moves the object along the x axis between two numbers set within unity. The script simply checks if the x position of the object is greater that the number set in unity. If it is, it will flip it's direction. This also works in the other direction. The object can be seen in the top right of the following GIF:
Also seen in this GIF is the enemy behaviour that I also created this week. The enemy instantiation occurs on the mouse position. This script uses a raycast, which takes the mouse's screen location when the left click is pressed and instantiates an enemy prefab that I created using the same model as the player. The navigation of the enemies to the player occurs using the Navmesh.SetDestination(player.position) function in unity. This function navigates a path across the NavMesh from its origin to the player denoted by the player.position.
The following GIF shows the enemies following the player around the scene:
UTAS KIT207 Portfolio
More posts
- Week 5 - Game IdeasApr 05, 2024
- Week 5 - Simple GameApr 05, 2024
- Week 4 - TerrainMar 22, 2024
- Week 3 - animations in unityMar 21, 2024
- Week 3 - animationsMar 17, 2024
- Week 2 - simple sceneMar 14, 2024
- Week 1 - Barrel and BridgeMar 10, 2024
Leave a comment
Log in with itch.io to leave a comment.