Enemies, Colors, and Platforms


Today I've added A Bunch of New Things To This In order to show what Ive learned in the past few weeks.

First you'll see is Keys now have colors! And will rotate between those colors automatically. The Next 4 Images are concerning how I managed to do that. First it checks to see if the number of keys or colors is greater than each other, or some similar situation, in order to prevent crashing. The next few images show how the colors change, how its done one at a time, and how the keys and colors get shuffled every time the list is forced to reset and shuffle, and to end the program once there are no more keys in the game.



Next off, enemies! Sort of... right now they are very crude and cannot move, but will gain physics when touched and vanish after some time, so they can be "killed" in a sense. In short, the code below is how the enemies spawn: first the location of the "spawners" are found and then enemies are spawned at those locations with the specified rotation as well. Once all enemies have been "killed" they all respawn!

Enemy Spawn Manager

Counts enemies, spawns them at spawners, respawns when all enemies have died.


Enemies and how they "Die"


I also quicky made health and mana "potions" that can be picked up and consumed. They crudely attach to the player and vanish upon use of left Mouse. On top of that, will only pick up if no other item is being held, and will notify the player for that!






Lastly,  I made platforms that can move and that can fall.

For the moving platforms, I simply set up a Blueprint with a simple platform and 2 static meshes. With that I can set the item to move through a timeline with LERP both back and forth over time, and will repeat forever.



For the falling platforms, It is remarkably more complicated. First the platforms need to check if the player had stepped on each one. If so, the platform changes color and sets a timer before falling.

For the "fall" physics get enabled and will drop to the ground, again changing color before setting a timer before resetting.

For the reset, it checks if the player is still on the platform, and only once the player moves off will it find its original location, and with timeline and LERP again, move back, which includes resetting its transform and rotation.







And that's everything! Its fun learning to code and use BPs.

Files

Build2.zip 761 MB
65 days ago

Get Coding 1-Summer 2024

Leave a comment

Log in with itch.io to leave a comment.