rimworld-animation-studio/Assets/Scripts/GUI/Chaser.cs

25 lines
633 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace RimWorldAnimationStudio
{
public class Chaser : MonoBehaviour
{
public GameObject target;
public bool chaseAlongX = true;
public bool chaseAlongY = false;
void Update()
{
if (target == null)
{ return; }
float x = chaseAlongX ? target.transform.position.x : transform.position.x;
float y = chaseAlongY ? target.transform.position.y : transform.position.y;
transform.position = new Vector3(x, y, 0f);
}
}
}