Herbal Dave's Adventure

Herbal Dave’s

Try to get Herbal Dave to be constructive today AND make it back home in one piece! It was fun to make this. Does anyone know the proper way to change, for example, the little picture of Dave in the upper left? Using states of course, I mean. Maybe to change to a shocked Dave when things happen in the game.

1 Like

Yes change the states so it is more interactive.

Really funny game, great job.

To change Dave’s image, you’ll need to add some variables and lines of code to your scripts, I don’t recall which are the scripts of the project, so I’ll write you a small guide on how to do it based on what I remember.

  • In your script that changes states, you’ll need a serialized ([SerializedField]) variable for Dave’s image. The variable type should be Image, if VS doesn’t allow you to use that type, you’ll have to add this line of code: using UnityEngine.UI; but I think you already have that line.

  • In your states, you’ll need a new variable, this time of type Sprite, it should be serialized too.

  • In your states you can add now a sprite from your assets, that would be Dave’s image for each state.

  • To end this, you’ll have to change the Dave’s image when a state changes. In your script that manages states, where the code updates the text, you’ll have to change Dave’s sprite; ‘_myImage.sprite = state._mySprite’. The underscore are there just to represent the name of the variables you previously created.

Hope this helps you, if this looks too complicated, try to think how you changed the text, the process is almost identical, the only things that change are the variable types.

Bro this is exactly what I was hoping for. Thank you. I appreciate it. I’m gonna go figure it out now.

@Yee thank you again - I was able to figure it out and make it work great, drew a few more Daves, and now it’s got an appropriate sprite for each part of the game! Newest version updated here. Knocked out a couple typos while I was at it lol.

1 Like

Privacy & Terms