Heroes_of_Hiis/Assets/Project Files/Scripts/JoonasP/FlyWand.cs

37 lines
637 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FlyWand : MonoBehaviour
{
private GameObject player;
private bool isFlying;
public float flySpeed = 10f;
private void Awake()
{
player = GameObject.FindGameObjectWithTag("Player");
isFlying = false;
}
private void Update()
{
if (isFlying)
{
player.transform.position += transform.up * flySpeed * Time.deltaTime;
}
}
public void EnableFly()
{
isFlying = true;
}
public void DisableFly()
{
isFlying = false;
}
}