- Home /
Roguelike turn movement and smooth step
Hey pals a pretty noob question: I'm trying to implement a simple roguelike just make a bit of experience with Unity.
I followed the 2DRoguelike example on the tutorial, but beside working, i find it a bit confusing on some parts.
I re-created something more GameManager\Actor\Action oriented pattern but i'm having some troubles on smooth movement and actors turns. I'll try to explain:
I would like to obtain something simple like:
GameManager has a loop to decide which actor has to act --> if the actor needs user input, the loop will wait for it -->--> when the input arrives, the GameManager have the direction where to move, and he instantiate a MoveToAction where basically i set the direction and the actor that have to move
At this point, the GameEngine notice that the actor has received the input (in this case for movement, would be the same for a spell or a potion drink) and goes on resolving the pending action on the actor that in this case would be a movement action in that direction.
If i simply set the Actor.transform.position = Actor.transform.position+direction everything works fine, actor got "teleported" to new location and ok, but immediately after all other non user controlled actor istantly take action. Which is fine, but is not really readable, with a lot of actors is a bit too fast.
So i tried to make this transition more smooth to make it readable, so each actor must move, the engine should wait for the actor to finish the movement and then go to next one, but acting outside a "Update" loop on the GameObject that has to move i dont know how exactly to achieve this, because the loop on the main GameManager cycle goes on and other actors take act while the other one still has to smooth move to the new target.
I'm looking for some suggestion\directions to take on this task which probably is really simple (in the 2D roguelike example this works but probably i did not understood the pattern correctly).
Thanks a lot from a beginner in Unity
Andrea, Italy
Answer by FabDynamic · Oct 24, 2017 at 01:06 AM
Two thoughts:
Look into LateUpdate() which is like Update() but effectively does things at the end of the frame. It may help.
Could you paste or screenshot some code?