| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Spirits_Dash : MonoBehaviour
- {
- public float moveSpeed;
- public Rigidbody rb;
- public Demonic demonic;
- public bool isDash;
- [HideInInspector]
- public float time;
- public float dashTime = 0.8f;
- public GameObject dashAttackEffect;
- public float offset;
- public DashEffect dashEffect;
- private void Update()
- {
- if (isDash)
- {
- time += Time.deltaTime;
- Dash();
- if(time >= dashTime)
- {
- DashAttackEffect();
- dashEffect.canHit = false;
- demonic.ChangeState(CharacterState.Fall);
- this.enabled = false;
- }
- if(time >= 1.33f)
- {
-
- }
- }
- }
- void DashAttackEffect()
- {
- rb.velocity = Vector3.zero;
-
- }
- private void Dash()
- {
- if (demonic.player.bodyTrans.localScale.x < 0)
- {
- if (demonic.bodyTrans.localScale.x > 0)
- {
- demonic.bodyTrans.localScale = new Vector3(-demonic.bodyTrans.localScale.x,
- demonic.bodyTrans.localScale.y, demonic.bodyTrans.localScale.z);
- }
- rb.velocity = Vector3.right * moveSpeed;
- dashEffect.offset = offset;
- }
- if (demonic.player.bodyTrans.localScale.x > 0)
- {
- if(demonic.bodyTrans.localScale.x < 0)
- {
- demonic.bodyTrans.localScale = new Vector3(-demonic.bodyTrans.localScale.x,
- demonic.bodyTrans.localScale.y, demonic.bodyTrans.localScale.z);
- }
-
- rb.velocity = Vector3.left * moveSpeed;
- dashEffect.offset = -offset;
- }
- }
- }
|