Search Unity

What is wrong with my overriding code?

Discussion in '2D' started by Th0masThe0bvious, Feb 16, 2019.

Thread Status:
Not open for further replies.
  1. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    Hi there; I am trying to do override voids based on documentation I have found online--both in video and textual form. Unfortunately, somehow my findings haven't taught me to write code that is accepted by the program, and while Visual Studio is great at telling you when code has problems, it's not great at telling exact solutions. At least, not in ways I can understand. So I'll post what code I've been trying, and hopefully someone can figure out what's wrong.

    Code (CSharp):
    1. public class BaseAction
    2.     {
    3.         public virtual void Current() {
    4.             Debug.Log("Stuff");
    5.                 }
    6.     }
    7.     public class IdleState : BaseAction
    8.     {
    9.         public override Idling()
    10.         {
    11.             Debug.Log("Other Stuff");
    12.         }
    13.     }
    The "Idling" part gives an error for me. The two messages I get are "The modifier 'override' is not valid for this item" and "Method must have a return type". I am not sure what these mean, and again, booting me to a Bing search (as opposed to internal documentation, which would probably be a better way to explain this) has not helped. So please tell me what's up here!
     
  2. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    Have you tried

    Code (CSharp):
    1. public override void Idling()
    2.  
    3. // Making the function not return a value
    4. //Could this be your error?
    I'm also wondering if maybe you should inherit Idling rather than BaseAction.

    Code (CSharp):
    1. public class BaseAction : IdleState
    2. {
    3.  
    4. }
    5.  
    6. public class IdleState : MonoBehavior
    7. {
    8.  
    9. }
     
    Last edited: Feb 16, 2019
  3. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    Yes. Still an error, though not the same. Now it is "'RobotAnimations.IdleState.Idling()': no suitable method found to override". Maybe that means a suitable state hasn't been added yet, but why not?

    Would that allow me to put other things there?
     
  4. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    Hmmm... Well, you got rid of the error requesting you to return, so that's good. Now you can do something like this:

    Code (CSharp):
    1. [SerializeField]
    2. private Animator anim;
    3.  
    4. // Then you put your animator component in this variable
    Now that you can access your state machine, you can call your state by name

    Code (CSharp):
    1. anim.SetTrigger("Idle");
    2.  
    3. // or whatever state name you chose for it ( might be "idle" )
    4.  
     
  5. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    Would "Idle" in that case be a void? Are such states mutually exclusive? Would the SetTrigger code be in Update?

    I ask about all this because I have been having trouble with switching walk animation to jump animation instantaneously, absolutely none of the common solutions will work for my game, and thus I have been looking to making each movement state its own void so those voids can be overridden by others. So far, though, this technique is a dead-end.
     
  6. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    Haa! I know exactly what you mean because I've dealt with the same problem myself not that long ago! I kind of figured this was the issue. I kind of know where your problem resides. How do you have your Animator transitional lines set up? The way I was able to overcome this issue was to design my animations and setup the transitional lines. I used SetBool parameters on those traditional lines. You can create a sub-Animator and make it specific for over-rides that are built-in. It took me quite some practice to understand it enough to make it work, however, it isn't super difficult so you're in luck, amigo!

    What you have to remember is that if you have "idle" set to IsRunning parameter false, and "IsWalking parameter set to false, you'll get a conflict. So I found that it is best to make a separate parameter for each corresponding state. And let's say you want to run, jump, and shoot then you wont really need but one override and that's the shoot animation.

    Edit: I said "Sub-Animator" however I meant a new Animator layer.
     
    Last edited: Feb 17, 2019
  7. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833


    Here's a nice tutorial that'll explain it better than I can. I cannot find the video I wanted to show you and I have been looking for hours
     
  8. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    On that note, do the conditions for the transitions have to be binary, or can I assign each state is own number and check for that? (Ie, 0 is idle, 1 is walk, 2 is jump, etc.)
     
  9. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    Yes, you'd use SetInteger("Idle", 0); SetInteger("Jump", 2); etc... You just have to set the parameter up and the conditions. The coding part is fairly easy for this. :)
     
  10. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    We
    I'm still having trouble with lagging jump animations. Here is my entire animation code; let me know if you would have done it differently.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Animations;
    5.  
    6. public class RobotAnimations : MonoBehaviour {
    7.  
    8.     // Use this for initialization
    9.  
    10.     Animator RobotMotions;
    11.     public bool jumping = false;
    12.     public float jumpTime = 0;
    13.     public bool grounded = false;
    14.     Rigidbody2D RobotBody;
    15.  
    16.     void Start () {
    17.         RobotMotions=GetComponent<Animator>();
    18.         RobotBody = GetComponent<Rigidbody2D>();
    19.     }
    20.  
    21.     // Update is called once per frame
    22.     void Update () {
    23.         //Each action in the animatior has its own number; 0:Idle, 1:Run, 2:Jump
    24.         float xMove = (Input.GetAxis("Horizontal"));
    25.         if (Mathf.Abs(xMove) == 0 && !jumping)
    26.         {
    27.             RobotMotions.SetInteger("Action Number", 0);
    28.         }
    29.         if (Mathf.Abs(xMove) > 0 && !jumping)
    30.         {
    31.  
    32.             RobotMotions.SetInteger("Action Number", 1);
    33.         }
    34.  
    35.      
    36.         if (Input.GetButtonDown("Jump") && grounded)
    37.         {
    38.             jump();
    39.         }
    40.  
    41.         if (jumping){
    42.          
    43.         }
    44.         if (jumpTime == 0)
    45.         {
    46.             if (Mathf.Abs(xMove) == 0)
    47.             {
    48.                 RobotMotions.SetInteger("Action Number", 0);
    49.             }
    50.             if (Mathf.Abs(xMove) > 0)
    51.             {
    52.                 RobotMotions.SetInteger("Action Number", 1);
    53.             }
    54.         }
    55.      
    56.     }
    57.     void jump()
    58.     {
    59.         RobotMotions.SetInteger("Action Number", 2);
    60.         jumping = true;
    61.         jumpTime = 100;
    62.         Vector3 velocity = RobotBody.velocity;
    63.         velocity.y = 5;
    64.         RobotBody.velocity = velocity;
    65.     }
    66.  
    67.  
    68.  
    69. }
    70.  
    It might be a good idea to show my whole project, since it's quite small and was made just to test this idea for animation transitions. I need to get to the bottom of this jump animation kerfuffle that has been plaguing my main game for months.

    Edit: As an update, "Exit Time" in my transitions does not stay at 0. For whatever reason, after testing the project and experiencing more animation lag, the Run to Jump transition exit time shows as some weird equation like 8.661828e-10. Not sure why it keeps resetting to that.
     
    Last edited: Feb 17, 2019
  11. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    that weird equation you're seeing is basically infinite, I think. However, I don't see anything in your code that would cause this to occur. unless it has something to do with your Mathf.Abs(xMove). Another thing, instead of doing a bunch of IF statements, use else if().

    Code (CSharp):
    1.  if (Mathf.Abs(xMove) == 0 && !jumping)
    2.         {
    3.             RobotMotions.SetInteger("Action Number", 0);
    4.         }
    5.         if (Mathf.Abs(xMove) > 0 && !jumping)
    6.         {
    7.             RobotMotions.SetInteger("Action Number", 1);
    8.         }
    9.    
    10.        else  if (Input.GetButtonDown("Jump") && grounded)
    11.         {
    12.             jump();
    13.         }
    14.       else  if (jumping){
    15.        
    16.         }
    17.        else if (jumpTime == 0)
    18.         {
    19.             if (Mathf.Abs(xMove) == 0)
    20.             {
    21.                 RobotMotions.SetInteger("Action Number", 0);
    22.             }
    23.            else if (Mathf.Abs(xMove) > 0)
    24.             {
    25.                 RobotMotions.SetInteger("Action Number", 1);
    26.             }
    27.         }
    28.    
    29.     }
    Sometimes this helps.

    Have you tried using SetBool("Jump", true) ?
    You can keep the same SetInteger() for the other states. I have also ran into an instance where Input.GetButtonUp() worked better for jumping than GetButtonDown.
     
  12. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    Code (CSharp):
    1. if(Mathf.Abs(xMove.velocity.x) == 0 && !jumping)
    You can try to use this code and see if that resolves your INFINITE issue.

    Also, something else I just thought of is once you SetTrigger() you can also use ResetTrigger().

    Code (CSharp):
    1.  
    2.             anim.ResetTrigger("Walk");
    3.             anim.SetTrigger("Idle");
    4.  
    This also might be part of your issue is that you set the integer but never reset it.

    Something else that I just discovered that seems useful is this:
    Code (CSharp):
    1. // Fast forward to the middle of the animation
    2.         anim["Jump"].normalizedTime = 0.5f;
    So if you needed to access a specific point in animation, or even cut your animation a little short this may be very useful?
     
    Last edited: Feb 17, 2019
  13. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    For some reason, that first "else if" statement controlling jumping doesn't work when the character is walking. Not just the animation lag this time; with that code for whatever reason, the character can't jump when walking.

    As to setting a bool, that is what I was trying earlier before this integer thing; not sure if it would work now.
     
  14. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    What does your debug log tell you when you run the code? Was it because of the Mathf.Abs(xMove.velocity.x) or just the else if() ?
     
  15. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    Okay; I added debug logs and the confirms that the jump can't work with walking. I ended up fixing that by copying the else if condition so now it's directly under both the idle and walk "if" statements. Sadly, this does not stop the walk animation from continuing past when it should based on the integer; whether the new state is jumping or idling. So either the issue is my code, my Animator, or something else. Want to examine the whole project?
     
    Last edited: Feb 18, 2019
  16. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    For some reason, I feel as though the integer isn't resetting properly and that's what is causing the problem. Are you able to debug log what happens to the SetInteger() value upon jump? Maybe if we can get this information we can create a solution? I'm suspecting when you're walking and jumping, the integer value keeps resetting to 1 or not resetting at all.
     
  17. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    To override methods, the signature (name, return type, visibility and parameters) needs to be the same in both base class and derived class, except for 'virtual' and 'override' keywords which you have in the correct place in your code already.

    I renamed your method and classes so that they makes more sense.

    Code (csharp):
    1.  
    2. public class BaseAction
    3. {
    4.   public virtual void DoAction()
    5.   {
    6.     Debug.Log("Base Action");
    7.   }
    8. }
    9.  
    10. public class IdleAction : BaseAction
    11. {
    12.   public override void DoAction()
    13.   {
    14.     Debug.Log("Other Action");
    15.   }
    16. }
    17.  
    Usage:

    Code (csharp):
    1.  
    2. BaseAction baseAction = new BaseAction();
    3. baseAction.DoAction(); // output "Base Action"
    4.  
    5. BaseAction idleAction = new IdleAction();
    6. idleAction.DoAction(); // output "Idle Action"
    7.  
    Extra reading:
    If you want both "Idle Action" and "Base Action" to happen when calling DoAction() on the derived class then do this:
    Code (csharp):
    1.  
    2.   public override void DoAction()
    3.   {
    4.     base.DoAction(); // base is a keyword that reference the base class and ignores overrides when you use it.
    5.     Debug.Log("Idle Action");
    6.   }
    7.  
    Usage:

    Code (csharp):
    1.  
    2. BaseAction idleAction = new IdleAction();
    3. idleAction.DoAction(); // output "Base Action" newline "Idle Action"
    4.  
     
    Last edited: Feb 18, 2019
  18. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    I have that pretty well coded, and upon running again it seems like two different things are causing the animation lag. In terms of going from walking to idling, the integer itself is slow to switch; that is, it does not immediately go back to 0 when I release the direction button. With jumping, the integer changes immediately but the sprite does not, so the character will start ascending before the animation has transitioned, for whatever reason.
     
  19. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    While that looks fine, for some reason I'm getting errors when I write code to trigger such actions with button input. Do I need to put it in a specific place in the script, or name a whole script "BaseAction"?
     
  20. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    What are the errors?
     
  21. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    Here is the code:
    Code (CSharp):
    1. void Update () {
    2.         float xMove = (Input.GetAxis("Horizontal"));
    3.  
    4.         if (Mathf.Abs(xMove) == 0)
    5.         {
    6.             DoAction();
    7.         }
    8.     }
    The error is "The name 'DoAction' does not exist in the current context" (Meaning its use in the Update, but I'm not sure why not).

    Edit: I figured it out; I need to include new update events inside of the new public classes. Testing now...

    Second Edit: The code does not execute in-game, however. Here is that revised code, for reference:
    Code (CSharp):
    1.     public class BaseAction
    2.     {
    3.         public virtual void DoAction()
    4.         {
    5.             Debug.Log("Base Action");
    6.         }
    7.         void Update()
    8.         {
    9.             float xMove = (Input.GetAxis("Horizontal"));
    10.  
    11.             if (Mathf.Abs(xMove) == 0)
    12.             {
    13.                 DoAction();
    14.             }
    15.         }
    16.     }
    17.  
    18.     public class IdleAction : BaseAction
    19.     {
    20.         public override void DoAction()
    21.         {
    22.             Debug.Log("Other Action");
    23.         }
    24.         void Update()
    25.         {
    26.             float xMove = (Input.GetAxis("Horizontal"));
    27.  
    28.             if (Mathf.Abs(xMove) > 0)
    29.             {
    30.                 DoAction();
    31.             }
    32.         }
    33.     }
     
    Last edited: Feb 19, 2019
  22. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    So do you think that perhaps
    Code (CSharp):
    1. anim["Jump"].normalizedTime = 0.5f;
    would be of use? You could try and capture the jump animation at the point it needs to be in order to compensate for the delayed integer switch?
     
  23. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    You're going to run into problems doing this. Unity lets you override Update and Start and other functions like that without override operators and to be frank, it's wrong and broken.

    As a result only one of those Update() functions will be called, but it's often confusing to know which especially if you add an Update() to a derived class in the future as you may have forgotten that the base class also has Update() defined and will no longer run, therefore changing behaviour and creating bugs in the future that you will not get a compiler error about.

    Because of this I'd advise never overriding Update, or to put it more simply, never define Update() or Start() or Awake() etc in both a base class AND a derived class. Decide now which should be responsible for it and ALWAYS stick to that.

    What you can do instead is this: (one of many possible workarounds)
    public virtual void UpdateModified() <= in the base class
    and public override void UpdateModified() <= in the derived class
    and then in Update() in the base class call UpdateModified();

    Or simply, don't use inheritance and find another way to do what you're doing.

    As to why your DoAction() is not being called even with the described problems above it should still execute from one of those two Update functions. Are you sure xMove is ever == 0 or > 0? which ever one of those functions is being called?

    I'd suggest attaching the debugger and stepping through the code to see exactly what is executing and why. If you have not used the debugger, I suggest you learn! It'll save you hours and hours and days and days of time if you plan to continue coding.
     
    Last edited: Feb 20, 2019
    MisterSkitz likes this.
  24. MisterSkitz

    MisterSkitz

    Joined:
    Sep 2, 2015
    Posts:
    833
    Very informative! I'm just glad I was a part of this thread to catch the information! I didn't think about having multiple Update() calls, especially with the derivative override functionality. Good stuff!

    Also, that's what I was thinking the problem is that the integer isn't turning into the proper number on call. However, he tells me that the actual problem is that it takes the integers an extra moment to change and therein is the problem. Which I'm not exactly certain how to fix this issue so at this point, I'm not much help to him.
     
  25. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    Sounds like an interesting idea, but as it is that yields the following error: "'Component.animation' is obsolete. 'Property animation has been deprecated. Use GetComponent<Animation>() instead. (UnityUpgradable)'". What would be the proper way to word that with this new syntax and my existing code? I can of course change the code if need be, but it has to be something that works. Right now I'm not sure what that "Jump" refers to or where in the project it would be. It's possible you were using Jump as an example, but I need to know this for sure because I'm not familiar with that coding technique.
     
  26. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    I note that Visual Studio (and probably Unity) requires me to include the word "void" after "virtual" and "override". Also the code passes in VS but still doesn't execute; am I missing something?

    Sadly, I have been looking for different ways for months, to no avail. One of the reasons I started examining override is that the "Ellen" 2D game kit used as an education resource uses it to animate good jumps. I chose that game as a model instead of the simpler platformer tutorials I found online because all of them simply check speed in order to trigger a running animation; that won't work in my game because it has moving platforms so sometimes the character will not be walking even while moving left or right. As Ellen also has moving platforms, I looked into the code to discover that overrides are used...but that code is way too complicated for me to reverse-engineer, which is why I've been researching overrides from square one. So I would rather not move on until I finally create an override system that works in and of itself, since that's the best chance it seems I have to get this animation right.

    Of course there might be another way to do this I'm not seeing...but my last topic on this died.

    It's always 0 by default, but because the checks for it and print commands are both within those virtual voids, they don't work. Here is the new code; devoid of errors according to VS but not functional:

    Code (CSharp):
    1. using System;
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class ActionSwitch : MonoBehaviour {
    7.  
    8.     public float xMove;
    9.     // Use this for initialization
    10.     void Start () {
    11.        
    12.     }
    13.    
    14.     // Update is called once per frame
    15.     void Update () {
    16.        
    17.  
    18.        
    19.     }
    20.  
    21.    
    22.  
    23.     public class BaseAction
    24.     {
    25.         public virtual void DoAction()
    26.         {
    27.             Debug.Log("Base Action");
    28.         }
    29.         public virtual void UpdateModified()
    30.         {
    31.             float xMove = (Input.GetAxis("Horizontal"));
    32.  
    33.             if (Mathf.Abs(xMove) == 0)
    34.             {
    35.                 DoAction();
    36.             }
    37.         }
    38.     }
    39.  
    40.     public class IdleAction : BaseAction
    41.     {
    42.         public override void DoAction()
    43.         {
    44.             Debug.Log("Other Action");
    45.         }
    46.         public override void UpdateModified()
    47.         {
    48.             float xMove = (Input.GetAxis("Horizontal"));
    49.  
    50.             if (Mathf.Abs(xMove) > 0)
    51.             {
    52.                 DoAction();
    53.             }
    54.         }
    55.     }
    56. }
    57.  
    By the way, while pasting this I noticed you seemed to suggest putting a call to "UpdateModified()" in the original Update event. I attempted that, and I got a "doesn't exist in the current context" error. So I'm really left with no clear way to call these newly defined classes to action, and need some pointers.

    Thanks for the suggestion. But first I want to solve the mystery of why my Visual Studio is rejecting so much code that is supposed to work.

    Something I want to state: I don't think I've ever before written a script that uses more than one class. There's the public class defined automatically based on what I name the script before opening it, and that's it. So I have no idea if putting multiple classes in a script is supposed to work, or whether they're supposed to be able to call each other. Also, whether base classes should be nested inside each other, though I've tried it both with and without that, to no apparent change. So far since starting this thread, I don't think I've been able to make any override script that actually works, which is disheartening.
     
  27. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    Yeah... sounds like you're in over your head a bit in the coding department. There's a lot going on here that I don't think you understand and could be simplified... It's hard for me to know how to help further without knowing the whole project and what you know which is a lot of work on my end. Sorry.

    The reason it 'doesn't exist' is because it's in a nested class. you need an instance of that class to call that function on. I'm not sure this is your intention though.. but here's how anyway:

    BaseAction action = new BaseAction();
    action.UpdateModified();

    if you want it to be an IdleAction then do this:
    BaseAction action = new IdleAction(); // because IdleAction inherits from BaseAction we can assign it to a BaseAction type.

    action.UpdateModified();
     
  28. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    I certainly don't want to get you bogged down in a big project, but fortunately, I don't really have to. What I think would help me most is if you please wrote a whole, but very short, script that does what you were talking about earlier using overrides: If nothing is pressed, it prints one message every update, if an arrow is pressed, it prints another.

    Simply being able to look at that script should be enough to let me know where everything has to be in a script involving overrides, and also what terms must be used for them to work. From there, I can move on experimenting on my own, probably determining rather quickly whether this can solve my animation problem.

    On the other hand, if what works on your end returns errors for me...well, something deep is wrong, and I'll need to go looking elsewhere to figure that out, maybe report a bug to the developers.
     
  29. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,778
    The problem is there are a number of ways to do that some will be helpful to you and some will not. without knowing the context I can't really be useful.

    You said you already had a project that uses them to implement things and that's why you're using them. Just copy what they did.
     
  30. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,463
    I've read most of this thread and if you are really only having issues with overrides and jumping as well as moving platforms, I would just try a different route altogether. I am working on a platformer where I am using Brackey's PlayerMovement and PlayerController codes and then GamesPlusJames' moving platforms video. My animations work properly, I can have a variety of moving platforms and havent had any issues. I know i just sorta popped in this thread but thought a different approach may help. The first couple Platformer videos from Brackeys and then this video:
    from GamesPlusJames helped a lot and it should only be like 3 or 4 videos to get everything working. If i am not even in the same wavelength as you and your problem, then i apologize and will disappear.
     
  31. Th0masThe0bvious

    Th0masThe0bvious

    Joined:
    Aug 22, 2018
    Posts:
    80
    I could try watching that, but last time I tried a Brackey's tutorial it asked me to download stuff that didn't work with my installation of Unity, so the tutorial was worthless.

    I think before I go further with this, I'd better refresh myself on how transitions are supposed to work, though I had thought I knew already.
     
  32. Cornysam

    Cornysam

    Joined:
    Feb 8, 2018
    Posts:
    1,463
    I feel ya on downloading stuff that doesnt seem to work, but I think in video #5 of his platformer, you dont have to download anything.
    . I relooked at his first few videos and they have you download art assets and such which you wont need to do. Try out the video #5 I linked, there shouldnt be anything to download.
     
  33. hunoristcool

    hunoristcool

    Joined:
    Aug 26, 2023
    Posts:
    1
    Do you know how to fix this error?

    MissingComponentException: There is no 'Animator' attached to the "Idle 0" game object, but a script is trying to access it.
    You probably need to add a Animator to the game object "Idle 0". Or your script needs to check if the component is attached before using it.
    UnityEngine.Animator.SetBool (System.String name, System.Boolean value) (at <734e2853606f4750b99ae351a5bc1b86>:0)
    Player.Update () (at Assets/Scripts/Player.cs:40)
     
  34. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,452
    The above necroed post is over 4 years old. Please check the dates of posts before replying.

    Thanks.
     
Thread Status:
Not open for further replies.