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
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...
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
Ill try to do better title problems XD Now serious i just want that he does the animations by order when your afk
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.
yes but i also want that he as a timer... but im still very noob and a beginer
i think i aswer your question above in Nose$$anonymous$$ills comment
I dont know why but that code also doesnt work it just do the same thing as always
Your answer
Follow this Question
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