This script handles moving a block in front of the player, simulating pushing.
Updates:
* Changed the E key to L to make it easier to use.
* Updated the if statement to check if the player is travelling, if so it will drop the object to stop it moving through time.
Start():
This will find the playerPushPosition transform which is at the front of the player by finding the player with the "Player" tag and getting the playerPushController transform which is referenced in the PlayerController.
Update():
This is used to allow constant movement to the object when required.
It has an if statement which will check if isPushing is true. If it is, it will call pushThis().
There is a second input which waits until the "L" key has been brought up or isTravellingTime is true. The "L" key is the interaction button in PlayerInteraction. If the "L" key has been brought up, it will set isPushing to false, stopping the object from moving.
Push():
This is called by PlayerInteraction an sets isPushing to true.
PushThis():
This has 3 if statements, all doing similar things. They move the GameObject this script is attached to on the X or Z axis to simulate pushing.
Currently, there is a bug when moving in only one axis, this is due to the world being set at a 45 degree angle.
Comments
Post a Comment