Last active
July 10, 2018 11:24
-
-
Save nomissbowling/26de7b867c79f429ae787dcc845d6cec to your computer and use it in GitHub Desktop.
ChaseTarget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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