Scrap Pirates – Big Game Project – Blog Post #3
|
This week for me has mostly been about creating moving platforms.
Most problems occurring whilst creating the moving platforms were simple mistakes with easy fixes, such as forgetting to create platforms that can go down/left, and not just right/up and able to go back their starting point. When a moving platform is placed in the game scene, both speed and what distance to move can be set. Then, the script of moving platforms will check if the distance is horizontal/vertical and if the ending position is bigger/smaller than the position the platform is starting from. Whilst the current position is not the ending position, the platform will move towards that position according to the set speed. If the “go both ways”-bool is checked, the platform will start moving back towards its starting position once it has reached the end position. The biggest problem that occurred whilst creating the moving platforms was that the players slide off horizontal moving platforms. My first attempt to solve this was by detecting the platforms’ change in position when the player was colliding with them, this failed however. How I solved this instead, was by making the platforms the players’ parent in the scene’s game object hierarchy when they are colliding, making the players follow the platforms wherever they move. When they leave the platform, they are no longer children objects of the platform.
|
