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 /
  • Help Room /
avatar image
0
Question by kimardamina · Sep 03, 2015 at 01:30 AM · script.slidercrashes

Game freezes and crashes everytime the player dies and I press the restart button

Hi Friends, I would like to have your opinion on what could be the problem I have facing. I have been working on this big pc game and I sort of ended up being stuck when I press the restart button to restart the level. So i tested with two different levels and imported the character and the terrain only in the second scene and as soon as it gets on the seconds scene it just freezes. This does this either it is in the editor or the built. So I started digging abit and realize that everytime that my player's slider life reaches to 0, and brings up the menu to restart the game, that is when the issue erupt. Whenever I do decide to restart the level at anytime before the player is completely dead, everything reloads fine and can move and stuff... So I am not sure how exactly would be the best way to fix this and still have the player die and reload the scene fine. Is it a bug in unity or something else? Can someone kindly share a solution? I also checked what goes on in the inspector, I realize that when i press restart, every single objects show deleted. alt text

unity-issue.png (14.7 kB)
Comment
Add comment · Show 1
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 BlackSnow_2 · Sep 03, 2015 at 01:42 AM 0
Share

We need more information. Give us your GameOver script and your PlayerHealth script.

Are you using Application.LoadLevel? If you aren't, are any non-instantiated GameObjects being destroyed on player death?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by kimardamina · Sep 03, 2015 at 08:31 AM

Hi BlackSnow, thanks for the reply. I am using Application.LoadLevel indeed. Here is the script used for the player's death which is attached on the enemy.

Here is the script attached on the enemy which reduces the blood of the main character on Trigger:

 public var mainCharacSlider:UI.Slider;
 public var mainMenu:GameObject;
 //play hit audio sound
 public var stebAudio:AudioSource;
 public var bloodFlick:GameObject; //Show the blood flickering on the screen
 
 function Awake(){
     mainMenu = gameObject.Find("MainMenu");
     mainMenu.SetActive(false);
     bloodFlick.SetActive(false);
 }
 function Start () {
     mainCharacSlider.value = 10.0f;
 }
 function Update(){
     var sliderValue = mainCharacSlider.value;
     /*if(Input.GetKeyDown("z")){
         // this is just to test 
         mainCharacSlider.value -= 0.1f;
     }*/
     if(sliderValue < 0.1f){
         mainMenu.SetActive(true);
         //Time.timeScale = 0;
     } 
 }
 //reduce the slider value when hitting the main character
 function OnTriggerEnter (col:Collider) {
     if(col.gameObject.CompareTag("Player")){
         mainCharacSlider.value -= 0.1f;
         stebAudio.Play();
         // activate the blood on the screen
         BloodFlicker();
         
     } else {
     return;
     }
 }
 //function to flicker the blood option
 function BloodFlicker(){
     bloodFlick.SetActive(true);
     yield WaitForSeconds(0.2);
     bloodFlick.SetActive(false);
 
 }

Then the menu pops up and it has a button to restart the game since you have died, and the script for that button is:

 function RestartGame(){
 Application.LoadLevel(Application.loadedlevel);
 }

I also tried to go back to another level by using the normal Application.LoadLevel("Name of the scene"), but as long as it had got the main character who as the slider it just freezes.

@BlackSnow_2 thank you for your assistance

Comment
Add comment · Show 4 · 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 BlackSnow_2 · Sep 03, 2015 at 10:00 AM 0
Share

Have you tried using the scenes' index number ins$$anonymous$$d? You can find it under File > Build in the top box (If it's not there click "Add current scene to list" or something of the sort).

avatar image kimardamina · Sep 03, 2015 at 10:07 AM 0
Share

@BlackSnow_2, I did try the numbering. The thing is it loads but nothing moves. the only object active are the backtrack sound, and if you put any button on there it will also be able to be pressed. Like UI elements work but no GameObject and script

avatar image BlackSnow_2 · Sep 03, 2015 at 10:28 AM 0
Share

What does your movement script look like? This is a really odd issue and I honestly cannot see why your game would be freezing or crashing.

avatar image kimardamina · Sep 03, 2015 at 11:17 AM 0
Share

The crazy part is that not only the charcter script stops. Like every single thing just stands still. Would you want me to send you a video maybe? I have scratched my head trying to understand this but nothing works

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Changing Graphic Levels Causing Crash 1 Answer

How to lock slider increase? 1 Answer

Why is my slider going to 100% in this coroutine as soon as it is run?,Why is my slider going to 100% as soon as the method runs? 1 Answer

link GUI slider to shader opacity 0 Answers

Slider isn't moving smoothly. (Unity3d) 1 Answer


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