To do this I have used Attributes. For the level which I am doing all my testing on, I have made 3 different Attributes. The Attributes type for each one of these is number.
- Battery Charge
- Stereo Charge
- Vacuum Charge
When the scene is created I have set all 3 of these attributes to 10
I have made it that every 4 seconds Stereo Charge goes down by 1, and that if Stereo Charge becomes 0 than the Stereo actor will die. The same thing is applied to the Battery Charge except for the every 4 seconds aspect of it.
I have created a region around the Stereo Actor. This is called Stereo Region
This region is so that if the Battery Actor is inside it that it has the ability to transfer its charge to the stereo.
For this to happen the Stereo first must be alive (have a stereo charge greater than 0) and if the battery actor is inside the region. Than if the enter button is pressed stereo charge goes up by 1 and the battery charge goes down by 1.
Here is all the code which i have used to create this
Here is also a video of what I just explained of how it would work in game
testing charge swap from Richard Hpa on Vimeo.
No comments:
Post a Comment