In this article we will prepare to a create modular script for our enemy guards. When having individual scripts it will be harder to extend on it later if needed.
Our Guards should be moving along the Nav Mesh as well so we need to make sure they have the Nav Mesh Agent Component.
In this article we will animate our player when walking. We got our place holder player moving with our movement system. Let’s replace it by the final model and add the walk animation to it.
Transform Scale set to 1, 1, 1
Hide Mesh Renderer
In this article we will make the camera look at our player continuously.
To achieve this we created a script “LookAt” and attached it to our main camera. Since our main camera is used constantly, this is the only place it needs to be attached. (Our main camera switches position with the camera system)
After a quick search we found a easy function.
Actually this is all we needed.
[SerializeField] private GameObject _player;
void Update ()
In this article we will make the camera switch angles depending on where our player is moving.
Here are our Camera switch triggers (box colliders, Is Trigger checked). When the Player passes through them we want to change the Main Camera position to another fixed position.
In this article we will continue to work on our movement system. This part will focus on getting our player to move along a Nav Mesh. After a quick search in the documentation we found this:
1 Create handle to NavMeshAgent component
2 Assign handle to NavMeshAgent using GetComponent
3 Set destination of our NavMeshAgent to position of our variable hit
Important to add this library below or we won’t be able to use NavMeshAgent etc in our script. This is missing from the earlier reference link to the official documentation as well.
public class Player…
In this article we create our script to move to a point on the map that is clicked.
if Left click
then cast ray from mouse position
then debug log floor position
create game object at floor position
Create script and add it to Player gameobject.
RaycastHit hit is a variable that stores what the raycast has hit. Using hit.point we can get the world position to spawn the capsule at.
Ray ray is a Ray variable in which we set the origin point as Camera.main. …
In this article we will be adding audio tracks to our timeline.
So let’s get started.
Create Empty Game Object > Rename to Audio
Create Empty Game Object x2 > Rename to VO(Voice Over) and BGM (BackGround Music)
Set Transform to zero on all 3 objects
Drag VO and BGM into Audio game object
Add Component: Audio Source on VO and BGM
Timeline (panel) > R-Click > Audio Track (Can rename it from inspector)
Drag in the VO game object into the Audio Source
Drag in the VO audio asset into the Timeline