Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Sphere : MonoBehaviour {
- public GameObject cube;
- public Vector3 spherePos;
- public Vector3 cubePos;
- void Awake ()
- {
- }
- // Use this for initialization
- void Start ()
- {
- spherePos = this.transform.position;
- cubePos = GetCubePos();
- }
- // Update is called once per frame
- void Update ()
- {
- this.transform.position = Vector3.MoveTowards(this.transform.position, cubePos, 1);
- }
- Vector3 GetCubePos()
- {
- cube = GameObject.Find("Cube");
- return cube.transform.position;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement