You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
772 B
C#

using LanLib.UpdateManager;
using UnityEngine;
namespace Samples.UpdateManager
{
public class TestFollowTarget : AManagedBehaviour, IUpdatable
{
[SerializeField] private Camera camera;
private void Awake()
{
if (!camera)
{
camera = Camera.main;
}
}
public void ManagedUpdate()
{
if (!Input.GetMouseButton(0))
{
return;
}
var ray = camera.ScreenPointToRay(Input.mousePosition);
var xz = new Plane(transform.up * 10, transform.position);
if (xz.Raycast(ray, out float z))
{
transform.position = ray.GetPoint(z);
}
}
}
}