TheKingsRace/Assets/Scripts/PlayerScripts/DebugPlayer/DebugItems/dDash.cs
Melbyj1125 758f06f775 Updated Debug prefab to be the testing version
Update Inventory Selection to work with debug prefab
2021-11-05 13:07:04 -05:00

42 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using MLAPI;
using UnityEngine;
public class dDash : NetworkBehaviour{
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 (!IsLocalPlayer) { return; }
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);
}
}