- Home /
How To Do This?
Hey Everyone! I honestly, have no clue how to word this, I have had trouble looking it up and couldn't find anything. I'm sure I have saw this somewhere before, but I forgot.
I'm making a 2D RPG, and one of the main thing's that will happen, Is the main character will change his outfits when given. I wan't my character to go into a building with a certain outfit, then later inside the building, he will get a new outfit. I then wan't to make him wear this outfit for every building he enters, Instead of the old one.
I have made the outfits already, the art, ect. I just need to know this.
Just change a sprite of the outfit when entering building. Either keep references to different sprites in a script, or create few gameobjects with those sprites and activate/deactivate them when needed.
How could I make a system that automatically activates/deactivates the sprites?
You can place trigger colliders (collider with IsTrigger checked) on building entrances. Then in your player script (the object should also have a collider) detect trigger collisions. Inside check which building you entered and change outfit based on that. It would look something like this:
class Player : $$anonymous$$onoBehaviour
{
private void OnTriggerEnter2D(Collider2D other)
{
if (other.gameObject.tag == "Building")
{
ChangeOutfit();
}
}
}