mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-04-04 16:14:57 -05:00
Implemented Ragdoll kinda There are some issues with getting hit while ragdolling that need to be fixed Adjusted Dash Dash still needs some adjustments before being fully implemented
39 lines
1015 B
C#
39 lines
1015 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
|
|
public class Dash : MonoBehaviour{
|
|
public Vector3 moveDirection;
|
|
|
|
public const float maxDashTime = 1.0f;
|
|
public float dashDistance = 10;
|
|
public float dashStoppingSpeed = 0.1f;
|
|
float currentDashTime = maxDashTime;
|
|
float dashSpeed = 12;
|
|
|
|
CharacterController characterController;
|
|
|
|
void Start(){
|
|
characterController = this.gameObject.GetComponent<CharacterController>();
|
|
}
|
|
|
|
//UPDATE CHECK FOR MOVEMENT ONLY WHEN DASHING
|
|
void FixedUpdate(){
|
|
if (Input.GetKeyDown(KeyCode.E))
|
|
{
|
|
currentDashTime = 0;
|
|
}
|
|
if(currentDashTime < maxDashTime)
|
|
{
|
|
moveDirection = transform.forward * dashDistance;
|
|
currentDashTime += dashStoppingSpeed;
|
|
}
|
|
else
|
|
{
|
|
moveDirection = Vector3.zero;
|
|
}
|
|
characterController.Move(moveDirection * Time.deltaTime * dashSpeed);
|
|
}
|
|
|
|
} |