the animations block the movements of player
Hi, recently I started with unity and my first video game 2d and this have been a big dare for me .
My problem is … when I try to make the moves of my player using rigidbody2D or when I edit the “tranform.positions” My animations have conflict .
public class PlayerControler : MonoBehaviour {
//Animacion
private Animator animator;
//Movimiento
public float movSpeed;
**private Rigidbody2D rgbody;
void Start () {
//Cargamos las animaciones
animator = GetComponent();
**rgbody = GetComponent();
}
void Update () {
//MOVIMIENTOS
//Movimiento Vertical
**float vInput = Input.GetAxis(“Vertical”);
**rgbody.velocity = new Vector3(0, vInput * movSpeed, 0);
////Movimiento Vertical
float vInput = Input.GetAxis(“Vertical”);
transform.position += new Vector3(0, vInput * movSpeed * Time.deltaTime, 0);
//Validamos:
//si el juego esta en marcha (Play),
//si se ha pulsado alguna tecla “espacio o click”
bool gamePlaying = gameInterface.GetComponent().gamestate == GameControler.GameState.Play;
bool userActionTurbo = Input.GetKeyDown(“q”) || Input.GetMouseButtonDown(0);
bool userActionRemolino = Input.GetKeyDown(“e”) || Input.GetMouseButtonDown(1);
//if (gamePlaying && userAction)
if (gamePlaying)
{
if (userActionTurbo)
{
UpdateState(“coheteTurbo”);
}
else if (userActionRemolino)
{
UpdateState(“coheteRemolino”);
}
}
}
the code that has *** It was the one that tries with rigidbody2d, I do not know if it is understandable but I place the two solutions that I have tried
can someone help me and explain how I can generate movement to my character
Note:
when I have only the animation initial The game is ok, but when I add other animation (example coheteRemolino) the move no work.