Its probably a simple fix but i cant see it, can someone help me by just fixing the dash, when running/walking and pressing the dash button, player only dashes forward disregarding the facing or move direction? Thank you good people!
Yeah, transform.forward will give you the forward direction of whatever scene object contains that script. If you’re doing something like keeping a single parent object with movement / game scripts and then a child object with all of its scene representation, then you’ll need to specify that you want to use that object’s direction.
What I think you want is:
private void Dash()
{
currentDashTime = 0.0f;
if(currentDashTime < maxDashTime)
{
// You don't necessarily want "transform.forward", but the "controller.transform.forward",
// since this is the object actually moving.
//
// Also, you were multiplying by "dashForce" here and in the controller.Move line,
// which is probably an accident. With a variable name like "moveDirection",
// it's more readable / intuitive that this just be a unit vector providing orientation
//
moveDirection = controller.transform.forward;
currentDashTime += dashStoppingSpeed;
}
else
{
moveDirection = Vector3.zero;
}
controller.Move(moveDirection * Time.deltaTime*dashForce);
}