I am looking for the names of these keys I can not find them on the internet to give an action to my animator do you know the name of these two keys?
t
I am looking for the names of these keys I can not find them on the internet to give an action to my animator do you know the name of these two keys?
t
thanks for help
Did you mean to include an image of the keyboard you’re talking about?
Do you mean LeftArrow and RightArrow? Or some special keys?
Quand il bouge pour aller à droite et à gauche je veux connaître le nom des deux touches du clavier droit et gauche
Voulez-vous dire LeftArrow et RightArrow? Ou des touches spéciales? [/ QUOTE]
Est-ce que LeftArrow et RightArrow sont à droite à gauche du clavier?
Please take a picture of your keyboard, or find a screenshot online, and circle the keys you’re talking about. We don’t know which keys you mean.
Veuillez prendre une photo de votre clavier ou trouver une capture d’écran en ligne et encerclez les touches dont vous parlez. Nous ne savons pas de quelles clés vous parlez. [/ QUOTE]
c’est deux touches du clavier
KeyCode.LeftArrow and KeyCode.RightArrow
If those aren’t working, please post the code you’re using where you can’t get them to work.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class animation : MonoBehaviour
{
private Animator animator;
// Start is called before the first frame update
void Start()
{
animator = GetComponent(typeof(Animator)) as Animator;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.LeftArrow) == true)
{
animator.Play(“walk”);
Debug.Log(“droite”);
}
if (Input.GetKeyUp(KeyCode.RightArrow) == true)
{
animator.Play(“walk”);
Debug.Log(“gauche”);
}
}
}
KeyCode.LeftArrow and KeyCode.RightArrow
If those aren’t working, please post the code you’re using where you can’t get them to work.
it gives that but the problem is that the animation is executed once the key is released, how to do when it appears just above without releasing it?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class animation : MonoBehaviour
{
private Animator animator;
// Start is called before the first frame update
void Start()
{
animator = GetComponent(typeof(Animator)) as Animator;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(KeyCode.LeftArrow) == true)
{
animator.Play(“walk”);
Debug.Log(“droite”);
}
if (Input.GetKeyUp(KeyCode.RightArrow) == true)
{
animator.Play(“walk”);
Debug.Log(“gauche”);
}
}
}it gives that but the problem is that the animation is executed once the key is released, how to do when it appears just above without releasing it?
Remove the part where you tell it to play the animation after releasing the key?
if (Input.GetKeyUp(KeyCode.RightArrow) == true)
{
animator.Play("walk");
Debug.Log("gauche");
}
Supprimer la partie où vous lui dites de jouer l’animation après avoir relâché la touche?
if (Input.GetKeyUp (KeyCode.RightArrow) == true) { animator.Play ("marcher"); Debug.Log ("gauche"); } [/ code] [/ QUOTE] Je suis nouveau sur c # pouvez-vous me donner un exemple?
You probably just made a mistake with your GetKey* calls. For one, you used Input.GetKeyUp, and the other you used Input.GetKeyDown. It sounds like you want to use Input.GetKeyDown for both.