- Home /
Question by
Game_Maker21 · May 21, 2020 at 10:30 PM ·
inputfunctions
How do I make my player dash using Unity's new Input System in an Update function?
Hello, I am trying to u make my player dash using Unity's new input System but I can't find a way to do it :(
private void Awake()
{
controls = new PlayerControlls();
controls.GamePlay.Up.performed += dash => ???;
}
private void Update()
{
// Dash
if (??? && currentDash < 0)
{
anim.SetFloat("Velocity", 0);
currentDash = DashTime;
anim.SetBool("Dashing", true);
}
else if (currentDash >= 0)
{
anim.SetFloat("Velocity", 0);
//Dash Damage
Collider2D[] swing = Physics2D.OverlapCircleAll(attackPoint.position, AttackRange, enemyLayers);
foreach (Collider2D stab in swing)
{
if (!hitEnemies.Contains(stab))
{
hitEnemies.Add(stab);
if (stab.GetComponent<MaskedOrc>() != null)
stab.GetComponent<MaskedOrc>().TakeDamage(Damage);
}
}
currentDash -= Time.deltaTime;
}
else
{
hitEnemies.Clear();
anim.SetBool("Dashing", false);
rb.velocity = Vector2.zero;
}
}
private void FixedUpdate()
{
if (currentDash >= 0)
{
switch (dashDir)
{
case 1:
rb.velocity = new Vector2(-DashPower * Time.fixedDeltaTime, 0);
break;
case 2:
rb.velocity = new Vector2(DashPower * Time.fixedDeltaTime, 0);
break;
}
}
}
Comment
Answer by falconstrike209 · Aug 28, 2021 at 01:01 PM
controls = new PlayerControlls();
I don't know how to solve your main problem, but this appears to be misspelled, which will definitely give you errors
Your answer

Follow this Question
Related Questions
Help In Making a SphereCast for 3D Tire! Working RayCast Script included! 0 Answers
User typing input 1 Answer
How do I add/multiply input field boxes? 1 Answer
OnMouse menu 1 Answer
Speed pickup 1 Answer