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 Imeguras · Apr 21, 2016 at 04:10 PM · animationunityeditoranimator controller

Whats wrong with my code???

using UnityEngine; using System.Collections;

public class onplayeranimati : MonoBehaviour { public Animator anim; void Start () { anim = GetComponent(); }

 // Update is called once per frame
 void Update () {
     if(Input.anyKeyDown == false){
         anim.Play ("WAIT01",-1,0f);


     }else{

         if (Time.time == 10 && Input.anyKeyDown == false) {
         
     }else{
         if(Input.GetKey("w")){
             anim.Play ("Run00_F",-1,0f);

             }
         }
     }
 }

}

//and my animator is like entry going to wait00 and wait01 going to wait02 going to wait03 going to wait04 going to wait00 also the run and the damage are not conected but i dont care about those

Comment
Add comment · Show 3
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 Imeguras · Apr 21, 2016 at 04:12 PM -1
Share

Im going to go on holidays but they just take 5 days so be sure to give the aswers i need them... Thanks to all that help me out on this error I$$anonymous$$ NEWBIE dont rage quit on me...

avatar image NoseKills Imeguras · Apr 21, 2016 at 04:49 PM 0
Share

This in not an answer so it should be posted as a comment. I'll convert it this time.

If you want to increase the chances of getting an answer, write a proper description of your problem. I can see that you are using GetComponent() wrong but other than that i have no idea of what you mean by "wrong with your code". Does it not compile? Do you get an error? Or does it just do something else than what you expected?

These are all thing that are mentioned in the guidelines on the page when you post a question (as well as that you shouldn't use '???' in the title :) )

You can find info on how to use GetComponent by searching this site or google

avatar image Imeguras NoseKills · Apr 30, 2016 at 03:53 PM 0
Share

Ill try to do better title problems XD Now serious i just want that he does the animations by order when your afk

1 Reply

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

Answer by Soraphis · Apr 21, 2016 at 04:50 PM

if you've any question related to your code you should:

  • A, very important: format your code here niceley

  • B: tell what exactly does not work

  • C: explain what your code should do

A:

 void Update() {
     if (Input.anyKeyDown == false) { // dont check booleans like this
                            // do it like this: if(! Input.anyKeyDown)
         anim.Play("WAIT01", -1, 0f);
     } else {
 // at this point you can be sure "Input.anyKeyDown" is true
         if (Time.time == 10 && Input.anyKeyDown == false) {
 // you'll never get to this line here, because of your if above this will always be false
         } else {
 // this else part will always be reached if W is pressed
             if (Input.GetKey("w")) {
                 anim.Play("Run00_F", -1, 0f);
             }
         }
     }
 }


so technically you can shrink your code to this:

 void Update() {
     if (Input.GetKey("w")) anim.Play("Run00_F", -1, 0f);
     if (! Input.anyKeyDown == false) anim.Play("WAIT01", -1, 0f);
 }

this means, you start everyframe one of those two animations. and at this point i'd recommend you an animator tutorial, because i've the feeling that you don't know how to use the animator.

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 Imeguras · Apr 30, 2016 at 03:54 PM 0
Share

yes but i also want that he as a timer... but im still very noob and a beginer

avatar image Imeguras · Apr 30, 2016 at 03:55 PM 0
Share

i think i aswer your question above in Nose$$anonymous$$ills comment

avatar image Imeguras · May 01, 2016 at 06:24 PM 0
Share

I dont know why but that code also doesnt work it just do the same thing as always

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

92 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

Related Questions

change player position when animation in played 0 Answers

Why isn't my animation looping? 3 Answers

Animator Check the end of an animation 1 Answer

I can't see or access a state in the Animation Controler 1 Answer

Animation from child object overrided by its parent and won't show in game window 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