Hi there. I’m trying to make a game similar to Enter the Gungeon, but I’m having problems with a dodge roll-like mechanic. My problem here is that my character teleports instead of moving when she performs a combat roll (Shown in the video).
My code is as follows:
public void CombatRoll() //Right Click to Combat Roll
{
if (Input.GetMouseButtonDown(1) && rolling == false)
{
//Debug.Log("Rightclicked");
if (Input.GetKey(KeyCode.D))
{
Debug.Log("D");
animator.SetBool("CRolling", true);
rolling = true;
immune = true;
Vector3 rollDistance = new Vector3(+30, +0, 0f) * speed * Time.deltaTime;
transform.position = Vector3.MoveTowards(transform.position, rollDistance, speed * Time.deltaTime);
Debug.Log("CombatRollRight");
Invoke("RollCooldown", 1);
Invoke("ImmuneRoll", 0.4f);
}
}
}
How do I fix this? Thanks in advance.