I've coded in a dynamic way to allow any obect to be a pickup! All through the same code base as the object interactions. So now, if I give an object an interactable property, I can now set it as a static object for interaction, an area transition or an item pickup. Because they're all derivitives of the base subtitle system they all share the same functions which allows me to expenad on the whole system.
Not only that but I've also rewrote my code a bit to make it much more responsive. In the previous iteration I was using checks in the OnTriggerStay function to then do any actions, this was an issue, as I found out that this isn't ran until after or during fixed frames. Meaning that it is run at the end of every single computed frame, so any down or up button checks were delayed, resulting in un-responsive interactions.
I then decided to migrate the bulk of my code into the Update function as this is ran every frame in realtime and the results are great. The whole system works as it should now.
In the video below you can see the optimisations and workflow I've managed to create, allowing me quickly create more complex interactions with ease.
(Watch in full screen to see inspector)
On a more techy side; this is achieved using triggers, just like the static object interactions I've done previously. Because it uses the same code to pull a message from the donor object to display in the susbtitle system, it now also copies the model attached and instantiates it. This is then rendered to a texture and displayed on the same canvas as the text.
The only issue to this that I've noticed, is that if an object has a model with multiple meshes or elements it will not render on the canvas. I don't know why, but it does work for single meshes, so long as I make sure I combine all my assets on export it should work absolutely fine.
The onscreen prompts also work as they should. If you select no, then the object is placed back onto the ground. Pressing yes will remove the original and instantiated object from the game (and eventually add this to the inventory).
No comments:
Post a Comment