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 /
This question was closed May 11, 2020 at 12:45 PM by gf457767 for the following reason:

Answer was found

avatar image
0
Question by gf457767 · May 06, 2020 at 12:55 PM · player movementvolumepause menufreezingaccessing

Why the player's movement freezes when I change the game's sound effects?

Hi,everyone! The problem is: When I added on my settings menu a option to adjust the volume of the game and I played the first level,I could move my player without any problem,but when I activated the pause menu and clicked the menu option so that I could go to the main menu to change the volume again and I went back,my player couldn't move,I pressed "w" and it wasn't moving.I'll put the player movement script here:

 using UnityEngine;
 
 public class PlayerMoviment : MonoBehaviour
 {   //É uma referência para "Rigidbody" o "rb"
       public Rigidbody rb;
       public float forwardForce = 2000f;
       
     // Update is called once per frame
     //FixedUpdate é usado para brincar com o código
     void FixedUpdate() 
     {  //Adiciona uma força para frente
         rb.AddForce(0 ,0, forwardForce * Time.deltaTime);
 
         if (Input.GetKey("d"))
         {
           //É apenas executado se a condição é apresentada
           rb.AddForce(40 * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
         }
         
         if (Input.GetKey("a")) 
         {
            rb.AddForce(-40 * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
         }
 
         if (Input.GetKey("w"))
         {
           rb.AddForce(0, 34 * Time.deltaTime, 0, ForceMode.VelocityChange);   
         }
 
         if (Input.GetKey("s"))
         {
           rb.AddForce(0, 0, -34 * Time.deltaTime, ForceMode.VelocityChange);
         }
 
           if (rb.position.y < -1f) 
           { 
         
              FindObjectOfType<GameManager>().EndGame();
 
           }
        
        }
    }



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

  • Sort: 
avatar image
0

Answer by fblast1 · May 06, 2020 at 01:09 PM

How does it activate the menu itself ?

Do you manipulate timescale at any point of the pause?


Regards

Comment
Add comment · Show 15 · 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
avatar image gf457767 · May 06, 2020 at 02:11 PM 0
Share

I created a script called:Pause$$anonymous$$enu,when I press the Escape button it activates like other game that you can resume,go to the main menu or quit the game. The problem is that: $$anonymous$$y game starts with the main menu where you can click on:Start game button(starts the first level),Settings$$anonymous$$enuButton(Go to the settings options)and QuitGameButton(Closes the game). On the settings options,there is a slider that controls the volume of the game,for now it just changes the coins' sound-effects,beacause I didn't put any background music for the game yet. The script that controls the volume option on the slider is on the;Settings$$anonymous$$enuScript. After you change the volume on the slider for the 1st time it works perfectly...

avatar image gf457767 · May 06, 2020 at 02:15 PM 0
Share

But if you press Esc button activating the pauseScreen and click on the menuButton(Goes to the main menu) and enter on the settings menu, the first thing wrong is that the volume goes back to 0 on the slider after you pressed the menubutton and went back to the mainmenu but if you c hange it again or not,click the startgamebutton and loads the nextscene,the main character can't move when you press:w;a;s;d.That's my problem that I need help!

avatar image fblast1 · May 06, 2020 at 02:41 PM 0
Share

Well, If i got it correctly , then you are not keeping the slider values consistent between scenes one way of doing so to use PlayerPrefs to save,load as needed.

for the movement part, is there any log you got in the console ?

consider this scenario start>play>pause>menu>start>play does it move then without touching the slider ?


Regards

avatar image gf457767 fblast1 · May 06, 2020 at 03:17 PM 0
Share

Actually,after I read your reply to my comment,I made a test and I discovered that the problem is not the volume,but it is something else. I clicked on the Start Game button,then it loaded the level1,then I pressed Esc,clicked $$anonymous$$enu on the pause screen,went back to the main menu,then I clicked again on the start game button,loaded level1 and I couldn't move,so actually I found out that the problem is not the volume slider,but I still don't know what is causing this,I would really aprecciate if you help me,please!

avatar image gf457767 fblast1 · May 06, 2020 at 03:19 PM 0
Share

And for your 2nd question:no!. There isn't any log in the console.

avatar image fblast1 fblast1 · May 06, 2020 at 03:34 PM 0
Share

While the game is running try inspecting the loaded gameobjects and check if there is a script missing when loaded

Also try to put Debug.Log at some points to check if code reaches this part or not

lastly, how do u instance your player in game or do you put it in the levels scene manually?


Regards

avatar image gf457767 fblast1 · May 06, 2020 at 04:35 PM 0
Share

$$anonymous$$y player is a capsule,this is my first project so I wanted to create something simple,the capsule was the first thing that I added to the project,there are 5 levels for now in my project,I just duplicated the previously levels until I reached level5 so the capsule went along with the duplication

Show more comments
avatar image fblast1 · May 06, 2020 at 06:40 PM 0
Share

I've put your code in action for testing purpose with simple scene loading scenario I changed a bit for rigidbody assigning

     Rigidbody rb;
     public float forwardForce = 2000f;
 
     // Update is called once per frame
     //FixedUpdate é usado para brincar com o código
 
     private void Start()
     {
         rb = GetComponent<Rigidbody>();
     }
 
     void FixedUpdate()
     {  //Adiciona uma força para frente
         rb.AddForce(0, 0, forwardForce * Time.deltaTime);
 
         if (Input.GetKey("d"))
         {
             //É apenas executado se a condição é apresentada
             rb.AddForce(40 * Time.deltaTime, 0, 0, Force$$anonymous$$ode.VelocityChange);
         }
 
         if (Input.GetKey("a"))
         {
             rb.AddForce(-40 * Time.deltaTime, 0, 0, Force$$anonymous$$ode.VelocityChange);
         }
 
         if (Input.GetKey("w"))
         {
             Debug.Log("w presed");
             rb.AddForce(0, 34 * Time.deltaTime, 0, Force$$anonymous$$ode.VelocityChange);
         }
 
         if (Input.GetKey("s"))
         {
             rb.AddForce(0, 0, -34 * Time.deltaTime, Force$$anonymous$$ode.VelocityChange);
         }
 
 
     }


Regards

avatar image gf457767 fblast1 · May 06, 2020 at 09:48 PM 0
Share

I tried your code(you actually forgot to put the monobehaviour class in here,but its okay),but it didn't resolve my problem,my player still frozes after I click on the menubutton and play again.

avatar image fblast1 gf457767 · May 07, 2020 at 12:42 AM 0
Share

well , try to load between scenes without UIs by using a script and input from keyboard.

also do you mean freezing like hanged and you quit or it crashes the editor ?

if it doesnt crash the editor , check the Hierarchy while playing and look at the capsule does it have the script attached ?

and check in the console if the error messages is disabled


Regards

Show more comments

Follow this Question

Answers Answers and Comments

129 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

Related Questions

Cancel Touch on Pause 1 Answer

lower volume on audio clip C# 1 Answer

Android: Ringer Volume Control 0 Answers

Is it possible to change Audio Manager Volume by script? 1 Answer

Sound volume too low on Android... 3 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