2022-03-09 19:37:11 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2022-03-12 19:38:42 +00:00
|
|
|
using UnityEngine.Rendering;
|
|
|
|
using UnityEngine.Rendering.Universal;
|
2022-03-09 19:37:11 +00:00
|
|
|
|
|
|
|
public class FlyWand : MonoBehaviour
|
|
|
|
{
|
|
|
|
private GameObject player;
|
|
|
|
private bool isFlying;
|
|
|
|
|
2022-03-10 15:25:29 +00:00
|
|
|
public ParticleSystem particles;
|
2022-03-10 11:49:11 +00:00
|
|
|
public float flySpeed = 10f;
|
2022-03-10 15:25:29 +00:00
|
|
|
public float testForce;
|
2022-03-10 11:49:11 +00:00
|
|
|
|
2022-03-09 19:37:11 +00:00
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
player = GameObject.FindGameObjectWithTag("Player");
|
|
|
|
isFlying = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
if (isFlying)
|
|
|
|
{
|
2022-03-10 15:25:29 +00:00
|
|
|
//player.transform.position += transform.up * flySpeed * Time.deltaTime;
|
|
|
|
player.GetComponent<Rigidbody>().AddForce(-transform.up * testForce * Time.deltaTime);
|
2022-03-09 19:37:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void EnableFly()
|
|
|
|
{
|
|
|
|
isFlying = true;
|
2022-03-10 15:25:29 +00:00
|
|
|
particles.Play();
|
2022-03-09 19:37:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void DisableFly()
|
|
|
|
{
|
|
|
|
isFlying = false;
|
2022-03-10 15:25:29 +00:00
|
|
|
particles.Stop();
|
|
|
|
particles.Clear();
|
2022-03-09 19:37:11 +00:00
|
|
|
}
|
|
|
|
}
|