LegitTeddyBears

EnemyAI

May 31st, 2017
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class EnemyAi : MonoBehaviour
  5. {
  6.     //I feel like this shouldn't be explained
  7.     public Transform pointA;
  8.     public Transform pointB;
  9.     //How fast it moves
  10.     public float speed;
  11.  
  12.     // Update is called once per frame
  13.     void Update()
  14.     {
  15.         //Usng a Sin Fuction we will this object will move to pos A and pos B forever
  16.         transform.position = Vector3.Lerp(pointA.position, pointB.position, Mathf.Sin(Time.time * speed));
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment