Vonstaad
(Vonstaad)
April 11, 2018, 12:26am
1926
So this question is giving me a bit of déjà vu to a similar one that I got pretty recently. But that was resolved with the old version, I believe, so this gives me an opportunity to solve it with the new one.
I’ve fist created a child of the north wall actor. I’ve recolored it, shrunk it a bit and added a pivot for rotation:
https://i.imgur.com/8dLAiWX.png
Then I added the action interface to this actor to allow it to animate actions on its own in the action queue.
Then I added the following to its event graph:
https://i.imgur.com/U0CWJjb.png
So at the start of the game I bind the AttemptOpen event to the event dispatcher that is called every time a unit ends its move on a tile. When the AttemptOpen event is called I check that the unit that has ended movement has ended movement on the same tile as the tile occupied by the door. If it does, then I unbind, add edges to the north (through the door) and add an open door animation to the action queue.
On the event animate action I’m a bit lazy and don’t bother adding a switch to check if we are trying to launch the Open animation, since this actor only has one animation anyway. I’ve added a timeline with a float track that goes from 0 to 1 in one second and use this as input for the rotation of the door pivot. The result is the following:
https://thumbs.gfycat.com/PowerfulBasicAfricanelephant-max-1mb.gif
Hope that gives you a good starting point.
Note that this solution works pretty well for most games. However, if you have a map with hundreds of interactable objects on different tiles, all of them being checked every time a unit ends on any tile it is not very efficient. I have added a new system for object interaction in my internal build and all the needed components for it are actually already in the live build, just not very streamlined. If you are going to have lots and lots of doors and interactable objects in you game, let me know, and I will tell you how to set it up.
Tremendous “Thanks” for all you do to support this forum- the toolkit is awesome.
How in Hades did you add a Pivot to the door mesh? I have literally spent hours searching how to add a pivot to the mesh, in order to reference in the anim but did not find how to do it.
I don’t own a mesh editor FYI.
Again, thank you in advance.