GameObjects and Mobs

Modified on Thu, 25 Mar 2021 at 10:52 AM

In Voxel Play you can use gameobjects like mobs or other objects as usual (instantiate prefabs, use your own scripts, etc.). There's no restrictions of any type as Voxel Play just generates standard meshes, colliders and NavMeshes.


However, Voxel Play provides some helpers to allow your gameobjects to benefit from certain features like the smooth lighting, terrain detection and pathfinding:


The Voxel Play Behaviour script


You can attach the Voxel Play Behaviour script to the root of your prefab or gameobject. This script provides many options to optimize the interaction of the character materials and physics with the voxel world.

Check the Voxel Play Behaviour page for more details about the available options.



Before using a NavMesh agent...


Since Voxel Play generates the world procedurally, before you spawn a mob on certain position, you need to ensure there's a chunk already created there. The Voxel Play Behaviour script will ensure that the voxel chunk is created under your character position at all times, so use it.


Another common requirement is to ensure the NavMesh info is available before you spawn an agent or give it directions to move to another position. Read the "How to spawn objects or mobs safely" article for more info.


The demo scene Demo3_SimpleFlatTerrain provides an example of spawning enemies (cylinders in the demo) who follows the player using agents. Check the Demo.cs and FoeController.cs scripts included in the demo folders.



Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article