This script is not that difficult to understand. Basically the character moves at a certain speed in any direction. There are also waiting time implemented so that it wouldn't move all the time but to have mini breaks in between.
Procedural item spawning I wrote a script to make the engine spawn a game object of my choice near the object the script is attached to. I also used a simple for loop to limit how many items are spawned when the code is run. The picture below demonstrates the code in action. Every time the code is run, the object will spawn in random places in the given area. Item Pickup system The code for the pickup system was very simple. All it has to do, is to destroy the item when collided and increase the counter. Pickup system in action as seen in the video below. via GIPHY
Artificial intelligence - Patrolling and way points As part of my game I decided to use wooden crates as way points. Each crate has a tag which is also defined in the script that marks them as way points for the AI character to walk past. The code below defines the base values for the script above but also acts as a core for the patrol state. Using the script in the animator In order to pump life into the AI characters in my game I used Animator to link the patrol node to my entity as seen in the picture below. The AI character will keep on running from one way point to another because there is no exit state attached to the "Entry" node. Patrolling in action
Comments
Post a Comment