Instantly share code, notes, and snippets.

Embed
What would you like to do?
対象を追跡するコード
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FollowTarget : MonoBehaviour
{
[SerializeField] private Transform target;
void Update()
{
var diff = target.position - transform.position;
transform.rotation = Quaternion.LookRotation(diff, Vector3.up);
transform.position += diff.normalized * Time.deltaTime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment