Quantcast
Channel: Answers by "Kerihobo"
Viewing all articles
Browse latest Browse all 78

Answer by Kerihobo

$
0
0
if you have a characterController component, you can use controller.move(moveDirection * Time.deltaTime); where moveDirection is a variable you declared storing a vector3. (X, Y, Z) <--- 3 vectors. So something along the lines of public vector3 moveDirection; public float maxDashTime = 1.0f; public float dashSpeed = 1.0f; public float dashStoppingSpeed = 0.1f; private float currentDashTime; void Start() { currentDashTime = MaxDashTime; } void Update() { if (input.getButtonDown(KeyCode.Z)) { currentDashTime = 0.0f; } if (currentDashTime < MaxDashTime) { moveDirection = new vector3(0, 0, dashSpeed); currentDashTime += dashStoppingSpeed; } else { moveDirection = vector3.zero; } controller.move(moveDirection*Time.deltaTime); } the dashStoppingSpeed will increase every frame, and when it reaches 1.0f, your dash will stop. so decrease that if you want your dash to last longer. this should work, but I dont know how this will conflict with the rest of your character movement controls, adjust it to suit your needs :) I should warn you that I'm not at home so was not able to test this.

Viewing all articles
Browse latest Browse all 78

Trending Articles