I’m in quite a pickle right now. My goal with this script is to make a sideways (right/left) and forward individual dashes. It contains multiple problems and I consider myself a complete noob when it comes to scripting. If someone has an alternative or solution of some sort I would be eternally grateful. The problems with this script are quite a few:
(-)First when I rotate the camera the dashes don’t move relatively to it, that dash’s movement are always with relation the the X/Z world axis
(-)Second, when i try to make the forward dash (Q and E keys simultaneously) it registers the 3 different dashes, left, right and forward.
(-)Lastly my character is obviously affected by gravity, is there a way to disable it while I’m dashing.
//private var isDashing = false; was originally going to, but not using
var strength : int = 20;
var dashCost = 25;
private var canDash = true;
function Update ()
{
if(Master.StaminaPoints < 25 )
{
canDash = false;
}
else
{
canDash = true;
}
if(Input.GetKeyDown("e") && canDash == true)
{
Debug.Log("Dash Right");
gameObject.GetComponent(CharacterMotor).SetVelocity(Vector3.right * strength);
audio.Play();
Master.StaminaPoints = Master.StaminaPoints - dashCost;
}
if(Input.GetKeyDown("q") && canDash == true)
{
Debug.Log("Dash Left");
gameObject.GetComponent(CharacterMotor).SetVelocity(Vector3.left * strength);
audio.Play();
Master.StaminaPoints = Master.StaminaPoints - dashCost;
}
if(Input.GetKeyDown("q") && Input.GetKeyDown("e") && canDash == true)
{
Debug.Log("Dash Forward");
gameObject.GetComponent(CharacterMotor).SetVelocity(Vector3.forward * strength);
audio.Play();
Master.StaminaPoints = Master.StaminaPoints - dashCost;
}
}