Skip to content

Instantly share code, notes, and snippets.

@pr00thmatic
Created May 27, 2019 17:24
Show Gist options
  • Save pr00thmatic/9fa3ae6dcf03f637b2536673db3b8658 to your computer and use it in GitHub Desktop.
Save pr00thmatic/9fa3ae6dcf03f637b2536673db3b8658 to your computer and use it in GitHub Desktop.
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