Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
4
Question by zsero · Jan 02, 2015 at 11:06 AM · c#animationmovementcharacter

mystery RestartLevel function used in official tutorial

I am doing the official tutorial "Survival shooter". In chapter 6 "player health", we have the following snippet at the end of PlayerHealth.cs:

 public void RestartLevel()
 {
     Application.LoadLevel(Application.loadedLevel);
 }

Adding this function really confuses me. It is simply not explained in the video, it's not in the official documentation, which I guess means this is a project specific function, but it's totally hidden where is this called. I did a string search in the project folder and the only place where it can possibly be called is Assets/Models/Characters/Player.fbx.meta.

 ...

 - serializedVersion: 16
       name: Death
       takeName: Take 001
       firstFrame: 525
       lastFrame: 650
       wrapMode: 0
       orientationOffsetY: 0
       level: 0
       cycleOffset: 0
       loop: 0
       loopTime: 0
       loopBlend: 0
       loopBlendOrientation: 0
       loopBlendPositionY: 0
       loopBlendPositionXZ: 0
       keepOriginalOrientation: 0
       keepOriginalPositionY: 1
       keepOriginalPositionXZ: 0
       heightFromFeet: 0
       mirror: 0
       bodyMask: 01000000010000000100000001000000010000000100000001000000010000000100000001000000010000000100000001000000
       curves: []
       events:
       - time: .997762918
         functionName: RestartLevel
         data: 
         objectReferenceParameter: {instanceID: 0}
         floatParameter: 0
         intParameter: 0
         messageOptions: 0

 ...

I tried to find this string everywhere in the inspector, but I couldn't find it at all. What is this mysterious hidden way of specifying a string in a model file which calls the function defined in the cs script? Why is this not documented anywhere at all in the tutorial?

How can I see / edit the property of the model file where this function is called from?

When I remove the function from the cs script, I get the following error in console:

 'Player' AnimationEvent 'RestartLevel' has no receiver! Are you missing a component?
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 Landern · Jan 02, 2015 at 06:15 AM 0
Share

The method name can be whatever, RestartLevel is not something specific to unity as a method that is.

The point is, the animation event tries to invoke the RestartLevel method, the internal line in that method loads a level by the current level's index that you will see in the build settings.

I don't see that they added that method to the script in the officially listed script on 6 of 10, they do add it to a GameOver$$anonymous$$anager in the update method based off the player's health being less than or equal to 0.

I just watched the whole video, so, i'm not sure what you're looking at.

http://unity3d.com/learn/tutorials/projects/survival-shooter/player-health

2 Replies

· Add your reply
  • Sort: 
avatar image
16
Best Answer

Answer by HVent · Jan 07, 2015 at 12:48 AM

Hi. i can't speak english, but i try to type in english. using "google translate"... i think that the RestartLevel()function is called by animation event. if you go to project view - modles - characters and select player - animations tab in inspector, you can see to the "animation clip"( move, depth, idle) if you select to death clip and drag your scroll to bottom of the inspector, you can see the "Event" panel. there is downward-pointing arrow on right of Event panel. if you click the arrow, Editing Animation event dialog is opened and, RestartLevel() function is right there.

Comment
Add comment · Show 5 · 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 Lan01 · Jun 26, 2015 at 04:18 AM 0
Share

$$anonymous$$istery solved! Thanx!

avatar image tarod-net · Feb 09, 2016 at 05:21 PM 0
Share

Amazing! Thanks! :)

avatar image kuzimo · Feb 18, 2016 at 10:19 AM 0
Share

Unbelievable! Thanks x 10!

avatar image Billu · Apr 18, 2016 at 04:32 PM 0
Share

this is so hidden... but I remember hearing this in the tutorial video thanks!

avatar image alizbliz · May 15, 2017 at 09:15 AM 0
Share

You can see it on this part: https://unity3d.com/learn/tutorials/projects/survival-shooter/har$$anonymous$$g-enemies?playlist=17144 At 8:40

avatar image
0

Answer by emousavi97 · Jul 28, 2017 at 12:39 PM

Hi you will get the answer at chapter 7 , 8:12

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

9 People are following this question.

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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Character Animation Question (Bear Force One) 1 Answer

Making a bubble level (not a game but work tool) 1 Answer

No movement when animation plays (2d) 1 Answer

Enemy not moving towards Player 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