Files
yaoyanwei 2f2a601227 init
2025-08-04 16:45:48 +08:00

31 lines
721 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TcgEngine.FX
{
/// <summary>
/// FX that follows the mouse
/// </summary>
public class MouseFX : MonoBehaviour
{
public float speed = 20f;
void Start()
{
}
// Update is called once per frame
void Update()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Plane plane = new Plane(Vector3.forward, 0f);
plane.Raycast(ray, out float dist);
Vector3 tpos = ray.GetPoint(dist);
transform.position = Vector3.Lerp(transform.position, tpos, speed * Time.deltaTime);
}
}
}