A lot has happened since I’ve last posted, so I’ll try to catch up to myself. I do apologize as I’m trying to keep a regular blog post schedule, but with other events and spring rapidly approaching, I’ve been side-tracked here and there.
If I remember correctly, in my last post I had just finished placing the spinning coins around the map as well as adding textures to the terrain to give a more life like appearance. Well, since then I have:
- Added scripts to allow collection of the coins.
- Added a teleport system to move the player character to another location within the map.
- Continued changing and shaping the terrain.
- Given a swing-able weapon to the player.
Starting with the addition of collection script, this was achieved through some manipulation of a previous script as well as the addition of a counter placed in the user interface area, allowing you to see the coin count as you collect them. Within this code, you can see the script calling upon “coinscollect” which is linked to the coins placed around the map and as each one is destroyed, the counter is increased.
Next up, what I found to be a very arduous addition to the game was the teleporter or transporter for you Star Trek fans. The premise of this is to step into a location and have the player character be transported to a pre-designated secondary location in another location on the map.
Sounds difficult to start, as getting the player to randomly spawn in another location just sounds like a nightmare. In reality, the code was simple enough, but the design of the transporter was what gave me the most trouble.
After getting the code settled, it was a matter of getting both transported sized correctly, getting the script in the correct place (which the guy doing the tutorial mixed up a few times as well), and then animating the transporter. Now, the animation is a new thing for me, and some of you may not know what that is. Unlike the coins, where the script instructed the object to rotate at a constant rate, an animation where different positions are mapped out and combined over a time frame to give the object motion. This was also applied to the weapon later on.
Once the transporter was done, I initially thought to just duplicate my object before the animation was done. This was not a good idea and I recommend you make the final product (without attaching the script) before you duplicate it. This way, your animations stay the same and you’re able to just relocate the second transporter pad.
This is roughly what it looked like before the texture and animation was added to the warp portion.
Next was addition of textures and reshaping the terrain which I’ve covered before, so I won’t dive into details with that. You can see the final product of that work in the Featured Image of this article.
Last up is the weapon. Upon hearing that I was going to be learning to place in a weapon the game, and be able to use it made me ecstatic! I know this may seem like a small thing to some of you, but seeing as this is my first game, I’ve not done this and it gives me great joy to know that I can now implement this with other items later on.
To start, the tutorial instructed to simply use a cylinder to shape the weapon (a texture will be added at a later time). Then, that object is to be housed within the FirstPersonCharacter in order to have it move with the player and not remain stationary. Yes, this weapon is already equipped and cannot be dropped at this point…but who cares? You can smash and slash things!
Anyways…as mentioned before, an animation was added to the weapon to allow for it to move upon execution of a ‘swing’ key and code which will be added shortly. Then, after the animations completed, a key biding is made to allow for the weapon to act out the desired animation upon activation of the chosen key. Something I did struggle with here was that an ‘error’ message kept popping up to make the animation a legacy file. This example her is the area on in the program to find that. Under the debug option in the settings panel.
I know I glossed over some of these details a bit, but if you do have any questions about anything, feel free to leave a comment and I will try to get back to you as soon as possible! For the next blog, I should have some combat mechanics to show off! See you then!