Thursday 4 May 2017

Outside the Box Project Beta Work - Bubble Wrap Behaviour


One of our more strategic Defences was the BubbleWrap.


It worked by accessing the MoveEnemy script when a GameObject that had a rigidbody and was tagged as Enemy collided with the Trigger Box Collider of the BubbleWrap Defence. Once the GameObject that had a rigidbody and was tagged as Enemy entered the Trigger Box Collider, the MoveEnemy script Component was accessed and the speed value of that particular GameObject's Move Enemy script was halved.
Consequently, when the GameObject tagged as Enemy exited the Trigger Box Collider, that Component's speed value was brought back up to it's original value, which was accomplished by multiplying the halved value by 2.

I also controlled the Audio for the defence through these Collision Triggers. I have the appropriate Audio play when the tagged GameObject enters the Trigger Box and set to Loop. However I am not Stopping the Audio when the GameObject leaves the Trigger as it caused trouble with Enemies entering the Trigger, causing the Audio to play, but then when the Enemies left the Audio would stop, but there would still be Enemies in the BubbleWrap, which didn't make sense.

So I fixed this by simply setting the Loop Boolean (true or false) to False, that way the Audio could continue if required with Enemies still in the Trigger Box and the Audio would eventually stop of it's own accord when the total time of the Audio had elapsed. 

No comments:

Post a Comment