In Unity, I want to change the animation by pressing the → key,
I can't do well.
The setting of Unity is written as follows in visual studio as shown in the image.
public class PlayerMovement: MonoBehaviour
animator = GetComponent();
float x = Input.GetAxis("Horizontal");
else if(x == 0)
Please tell me where to fix.
If i do not understand the situation, I will upload additional images, so please tell me the necessary information.
Answer # 1
The following two are premised.
PlayerAnimation = state with animation in idle state assigned to Motion
RunAnimation = State with running animation assigned to Motion
First, it's a good idea to lay out the Hierarchy, Scene, Game, and Animator windows so that you can see them at the same time.
Leave the PlayerMovement component disabled.
Run the scene and select the object that has the Animator component added to it to activate the Animator window. In this state, there should be an indication that "PlayerAnimation state is playing".
Now, rewrite the Animator parameter "Speed" to 1. After that, the state will transition to RunAnimation, and the Animator window will show that as well.
Then set Speed back to 0. If Transition of RunAnimation → PlayerAnimation is set properly, the state will return to PlayerAnimation.
Stop execution and enable the PlayerMovement component.
Run the scene and press →. If the PlayerMovement and Animator components were attached to the same object, the Speed parameter would now increase and a State Transition would occur.
If not, please tell me at what step you were in a different situation than what was written and what was different.
By the way, Transition's Has Exit Time is checked, but this means that the transition before the animation before the transition is played to the end is completed, so in this case you should uncheck it.
- c # - animation to change the direction of the character (bool)
- c# - i want to change the animation of mecanim in unity
- is it possible to change the character string with unity character string animation?
- unity - i want to start the animation set to set as layer default state after the animation when hitting the enemy is over
- c# - unity how to set the position and animation of the generated object
- [opencv for unity] i would like to change to a codec (mp4 or mov) that can be read as the virtual movie background of zoom when
- [opencv for unity] i would like to change the codec when saving a video with the videowriter function to mp4 or avi
- c++ - is there a way to change the sdl library character code when passing it as an argument in the source code?
- unity rich text color change
- c# - i don't know unity [how to change object position according to story like rpg game]
- c# - change ui when ch5 arrow of unity textbook 2019 hits
- python - i also want to change the character defined with for
- c# - i want to change the contents of a variable when i exit the [unity] state
- c# - [unity] how to activate character and command separately with different buttons
- c# - unity: i want to change the orientation (left or right) of an object while dragging
- unity animation only plays for the first second
- unity2d diagonal movement animation management
- you cannot change it by dragging it into the unity inspecter window
- c # - the player character of unity rotates
- c # - unity 2d breakout: i want to double the score for consecutive hits
- c# - unity visual studio
- unity - solution explorer in visual studio is empty
- unity c# if statement
- c# - to use resourcesdesignercs created in visual studio with unity
- c# - i want to change the time until i have an item for each item
- c # - code error of script implemented by unity cannot be resolved
- how to set up the editor in unity
- unity - about the means of writing novel games