TinyGo has 2 features: PathFinder and Chunk
So how they work?
PathFinder uses Godot NavigationAgent3D to find the nearest path to the target. It returns
the Vector3 of the target Location and then you can apply the position of your enemy or
anything you want it to go to a target point with the given path from PathFinder.
Chunk uses tscn scene file as Chunks to load on given distance and unload when out of
range. Chunk also has preload feature that it instantiates on given distance of preload
distance before reaches the distance to make the chunk visible. So that makes sure that
the chunk is ready before the player reached the visible distance.
Example code:
PathFinder:
Code above shows the example to setup and apply the position to go to the target position.
Target can be anything you want as the location you want it to go. This can be useful for
enemy to chase player that it doesn’t walk blindly and hit the wall.
Remember to always add NavigationAgent3D to the chaser node and
always bake the NavigationRegion3D to make it works.
Chunk:
This code above shows the example of making a chunk instance. Using Chunk
in TinyGo is one tscn chunk per instance so when you have multiple chunks,
you need to add new Chunk instance for them. This ensures the chunk is
independ and not crashing other. The LocationNode is where the chunk will
appear when the player is within the given distance.
Enabling Preloading is recommended because it makes sure the chunk is
ready before the player enters the distance range.