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 Jul 16, 2016 at 07:36 PM by MegaWave_ for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by MegaWave_ · Jul 16, 2016 at 06:55 PM · c#updatemonobehaviourstartawake

Update and Awake not being called.

I have this script which is completely fine and stuff, but does not call Update and Awake voids, it only calls voids when they are called manually from other scripts (for example "MoveToPlayer" which is called from the enemy area script)

 //removed all stuff not related to the answer since I am really careful when sharing my scripts since I dont want bad people to steal it

 using UnityEngine;
 using System.Collections;
 
 public class basicEnemy : MonoBehaviour {
 
     private Animator anim;
  
     void Awake()
     {
         Rest();
         anim = gameObject.GetComponentInChildren<Animator>();
     }
 
     public void Rest ()
     {
         anim.SetBool ("walking", false);
     }
 }
 
 
         
         






Comment
Add comment · Show 2
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 wojtask12 · Jul 16, 2016 at 07:18 PM 0
Share

You sure you've got an instance of enemy class in the scene? What about "OnEnable" and "OnDisable", do they work? Post the original class, we can't help you without seeing the code

avatar image MegaWave_ wojtask12 · Jul 16, 2016 at 07:21 PM 0
Share

On Enable and On Disable don't work, also I'll post the original script in just a second. EDIT: ok I have now posted the original script

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by wojtask12 · Jul 16, 2016 at 07:25 PM

You should be getting a null reference error, due to calling anim variable in the Rest() function before assigning it with GetComponent. Perhaps you turned off error logging in the console by accident

Comment
Add comment · Show 3 · 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 MegaWave_ · Jul 16, 2016 at 07:33 PM 0
Share

Thank you so much! I thought it just was not calling the functions when I just happened to make a stupid mistake like that :) Thank you for your help, you saved my life today :3

avatar image MegaWave_ · Jul 16, 2016 at 07:34 PM 0
Share

How do I mark this the correct answer?

avatar image wojtask12 MegaWave_ · Jul 16, 2016 at 07:36 PM 0
Share

I just converted the comment to answer, i guess you can mark it now

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

C# void names 1 Answer

Initialising List array for use in a custom Editor 1 Answer

start called directly after instantiate? 1 Answer

Does the access modifier of Start(), Awake(), OnEnable() make a difference to Unity? 3 Answers

Instantiated Prefab not calling Start() nor Awake() 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