Created
May 27, 2019 17:24
-
-
Save pr00thmatic/9fa3ae6dcf03f637b2536673db3b8658 to your computer and use it in GitHub Desktop.
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 System.Collections; | |
using System.Collections.Generic; | |
public class Motion : MonoBehaviour { | |
public GameObject target; | |
public float speed = 5; | |
void Update () { | |
float deltaDistance = Time.deltaTime * speed; | |
transform.position = | |
Vector3.MoveTowards(transform.position, | |
target.transform.position, | |
deltaDistance); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment