Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created November 30, 2018 12:49
Show Gist options
  • Save tsubaki/f16e02a9332ce2defda8c3c7f4b8ae9c to your computer and use it in GitHub Desktop.
Save tsubaki/f16e02a9332ce2defda8c3c7f4b8ae9c to your computer and use it in GitHub Desktop.
対象を追跡するコード
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