Ball task

ball changing colour.gif

For this we were left to our own devices with the internet to hand. This opened an endless amount of possibilities for what we could come up with. We were told to make a ball and add some code to it which would make it do something. I stumbled across some code which involved using Nav Meshes. This enabled me to make the ball randomly move to locations within a set radius.

auto move.PNG

I made public variables so I was able to change then using the unity editor, this was just a to make it more convenient as it made it easier to edit things such as movement speed and the interval time for it relocating. I then had to add a ground plain then bake it to allow the nav mesh to function.


After I had it moving automatically I then wanted to add a little more so I added some code to make it automatically cycle through colours this however was not good enough as it only went though colours I had set and this was a lengthy process so I then adapted this code to automatically choose colours from the colour picker.

click colour.PNG

This is the code to change colours of the ball then you click the ball. It uses the ‘on mouse down function’

I also made an automatic scaling function to make the sphere pulsate so it grew and shrank automatically and in a sequence. The rate of the pulsating also corresponds with the changing of colour which I thought was really good.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s