ok, first, i gotta tell ya guys that i copied this script from a fps game where the player could strafe left and right… but just because i have no idea how to move my character
var dashSpeed = 12;
var dashJump = 2;
var dashing = 0;
private var moveDirection = Vector3.zero;
private var dashIsTrue : boolean = false;
function FixedUpdate() {
if (dashing > 100) { moveDirection = Vector3 (0,0,0); dashing = 0;}
if (Input.GetButton ("RightDash")) {
SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);
dash();
}
if (Input.GetButton ("LeftDash")) {
SendMessage("DidJump", SendMessageOptions.DontRequireReceiver);
dash2();
}
// Move the controller
var controller : CharacterController = GetComponent(CharacterController);
var flags = controller.Move(moveDirection * Time.deltaTime);
dashing ++;
}
var DashCooldown = 2;
private var DashTime = 0;
function dash()
{
if (Time.time > DashTime)
{
moveDirection.x = dashSpeed;
moveDirection.y = dashJump;
DashTime = Time.time + DashCooldown;
dashing ++;
}
}
function dash2()
{
if (Time.time > DashTime)
{
moveDirection.x -= dashSpeed;
moveDirection.y = dashJump;
DashTime = Time.time + DashCooldown;
dashing ++;
}
}
@script RequireComponent(CharacterController)
well… its working a little buggy… but the main character is actualy dashing left and right… but what it want is… to add a foward dash, instead of going only trough the X aspect i want to be able to dash into Z too
someone can help me by editing my code or just throwing the a part of the code where the character moves forward?
or if someone knows a diferent way to do it, diferent from this script i pasted … i accept that too
like… a script where checks if dash key is pressed, addforce to the player go forward… to me thats good too