Skip to content

Instantly share code, notes, and snippets.

@nomissbowling
Last active July 10, 2018 11:24
Show Gist options
  • Save nomissbowling/26de7b867c79f429ae787dcc845d6cec to your computer and use it in GitHub Desktop.
Save nomissbowling/26de7b867c79f429ae787dcc845d6cec to your computer and use it in GitHub Desktop.
ChaseTarget
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System; // Math
public class ChaseTarget : MonoBehaviour {
int cnt = 0;
void Start(){
}
void Update(){
++cnt;
//if(cnt % 60 == 0) Debug.Log("ChaseTarget: " + cnt);
Vector3 unitypos = GameObject.Find("Unitychan").transform.position;
Vector3 enemypos = GameObject.Find("Enemy").transform.position;
//Debug.Log("unitypos: " + unitypos.x + ", " + unitypos.z);
//Debug.Log("enemypos: " + enemypos.x + ", " + enemypos.z);
Vector3 offset = new Vector3(
(unitypos.x - enemypos.x) / 360, 0, (unitypos.z - enemypos.z) / 60);
GameObject.Find("Enemy").transform.position += offset;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment