Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Clypso · Apr 01, 2019 at 05:46 AM · character2d-platformerenvironmentclothing

Changing my character's clothes and environment in 2D

I am doing a game which player pressed a f button the environment and character's clothes change. Like a two scene almost fimiliar but I want it to be not seperate scene, I want it in the same scene. I am focusing on a dream theme so when I press f, environment and my character chance a bit to show that dream theme. Is there any guideline or idea which can help me while writing it's code? It is 2d game.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by surfuay · Apr 03, 2019 at 04:19 AM

you could make all the clothing a child of the player and in the player script you just say when you press f it sets some of them active to true and others to false, you could do the same with the environment.

I would put all that in the player script since it's the play that affects the changes.

I can't remember the code off the top of my head but I believe it would be something similar to

  //i'd put this in my game manager or some manager script
  public bool asleep = false;

  void Start()
       {
          asleep = false;
       }

this part would go in my player script

  void Update ()
  {
         Dreaming()
  }

  public void Dreaming()
  {
       if (input.getkeydown(keycode.F))
       {
            //you'll need to access the manager Script, that you put the bool in, here
            if (GameManager.gameManager.asleep == false)
            {
                 GameManager.gameManager.asleep = true;
                  //these clothes are children of the player, the clothes would start as active and the sleepClothes as inActive (you set that in the editor)
                 clothes.setActive(false);
                 sleepClothes.setActive(true);
                 //you'll need to access another script that controls the background here, you'll want to make that script a public static backGround (whatever you name it)
                 Main.backGround.awakeBack.setActive(false);
                 Main.backGround.asleepBack.serActive(true);
           }
           if (GameManager.gameManager.asleep == true)
           {
                 GameManager.gameManager.asleep = false;
                  clothes.setActive(true);
                 sleepClothes.setActive(false);
                 Main.backGround.awakeBack.setActive(true);
                 Main.backGround.asleepBack.serActive(false);
            }
       }
  }

SO, if i did this I'd have 3 scripts GameManager which controls my overall bools BackGroundManager which would go on my mainCamera for a 2D game Player Script

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

143 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to import multiple UV Maps for a mesh into Unity? 0 Answers

How to prevent friction for character along vertical surfaces? 2 Answers

How can I attach clothing to the character? 1 Answer

adding multiple clothes to character,equipting multiple clothes to character problems 1 Answer

Platformer Flipping 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges