Help regarding Entities (NPc, Enemies) turn based movement

Announcements, support questions, and discussion forum for Grid Controller.
Post Reply
niokasgami
Posts: 2
Joined: Wed Apr 17, 2024 3:35 pm

Help regarding Entities (NPc, Enemies) turn based movement

Post by niokasgami »

Hi,
I want to say I absolutely love the grid controller assets its simplify everything when its come to implement the system.

I was although unsure how to approach the movement for the enemies and npc to be also turn based.

if I am wrong and its not the proper forum I apologize.

How would I approach to create the enemies to be turn based (aka only when you move)?
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Help regarding Entities (NPc, Enemies) turn based movement

Post by Tony Li »

Hi,

Thanks for using Grid Controller!

I recommend having a "game manager" or "turn manager" script that manages turns. When you process a turn, call GridController.Instance.ProcessTurn() to process the player's movement and also call whatever code you need to move enemies and NPCs.

You might be interested in using Aron Granberg's A* Pathfinding Project. (It's 50% off right now in the Spring Sale.) It can handle grid-based movement for enemies. See also A* Pathfinding Project's Utilities for turn-based games documentation.
niokasgami
Posts: 2
Joined: Wed Apr 17, 2024 3:35 pm

Re: Help regarding Entities (NPc, Enemies) turn based movement

Post by niokasgami »

Hi thank you!

I though I assume the movement would be similar to how you do the movemen with grid controller. Although, as I appreciate the offers of the A* plugin I sadly dont have the funds for it so ill try to do my own approach for it.


of what I understand everytime I move right it will trigger process turn or I gotta push it myself?
User avatar
Tony Li
Posts: 22104
Joined: Thu Jul 18, 2013 1:27 pm

Re: Help regarding Entities (NPc, Enemies) turn based movement

Post by Tony Li »

Hi,
niokasgami wrote: Wed Apr 17, 2024 5:23 pmI though I assume the movement would be similar to how you do the movement with grid controller.
Yes, but simpler in a way since your code controls the AI instead of movement being at the whim of the player. It really depends on your game. In Wizardry, for example, the player just moves and encounters randomly pop up. There's no need for any kind of movement. Many dungeon crawlers use very simple movement logic: if the player is nearby, the enemy will turn to face the player. Then it will move forward one square each turn until it's next to the player. That produces very decent behavior without the need for any pathfinding. If you do need something more complex, there are many tutorials (here's one) on how to pathfind on a grid.
niokasgami wrote: Wed Apr 17, 2024 5:23 pmof what I understand everytime I move right it will trigger process turn or I gotta push it myself?
It's the opposite. When your game is ready to process a turn (e.g., let player move, let NPCs move, etc.), call GridController.Instance.ProcessTurn() to push it.
Post Reply