Gamespace: Moving Platform

Moreover, I wanted to include a moving platform to make my Gamespace more exciting and add difficulty. This functionality was added before I re-coloured the assets.


Platform moving up


Platform moving down


The 'Moving Platform' script is attached to the moving platform in the inspector.


Moving platform Inspector



The 'MovingPlatform' script declared the Vector3 variable 'initialPosition' as private meaning that the value does not need to be changed outside of the script in the inspector.

My initial position which can be taken from the command 'transform.position' is stored in the 'initialPosition' variable.
The transform.postion is set every frame and equals wherever I was located initially (stored in initialPosition) with the addition of an offset where a new 3D vector is created. The X-axis is equal to zero, the Y-axis is equal to a Sin wave that alternates multiplied by five to give a larger wave meaning that the platform will move up and down in the Y-axis. The Z-axis is set to zero as the platform is not moving in this direction.



Moving Platform Script

Comments

Popular posts from this blog

Unity Project 4: Ball platformer game

[Research] Traditional Poster Design (4CTA1214)