Interacting with tools and changing stats

 Messaging

In order to dictate when the intractable objects should activate its animations and other functions, i used the built in messaging system in unity. This is used to send a command to use a certain function within another script. This is an easy way to control a small amount of functions on a global scale.

Shower

The shower is composed by a collision box, a particle effect and a static 3D model. The whole system starts when the player touches the screen and the ray collides with the collision box in the shower. Here the message is sent to the shower to play the function controlling the particle effect. So the shower can never run without the player touching it. To then ensure that the critter is affected by the shower, i had to create an area-of-affect. I created a function in the script that describes a square just beneath the shower. The shower also keeps track of the position of the critter. With these to variables i can see whether the critter is beneath the shower or not. If it is, the shower in turn sends a message to the critter to run the function for showering. This function changes the animation and cleanliness-stat of the critter to show, with the showers particle system that the shower is on and cleaning the critter. However, if the critter is outside the square, the message will never be sent and only the particle system will be playing, indicating that the critter is not affected by the shower.

Brush

The brush is using a similar system. It has a collision box through which a message is sent when the player is touching it. The difference here is that the brush, when activated follows the movement of the players touch. If the player releases the touch, the brush returns to its original position or ”station”. When the brush is touched a particle effect is activated, visually showing the player that the brush is ”On”. I then created, like with the touch system, a ray that shots out from the brush in the direction of the critter. Rather the whole brush is always pointing its brushes towards the critter, to ensure that the brushing looks correct no matter the positioning of the critter. If this ray then collides with the critter, the critter will be brushed and the happiness-stat will increase. To show to the player that this works the brush sends a message to the critter to activate the brush function, which changes the animation of the critter.

About Christoffer Tornstråle

2015 Programming