I'm trying to make a ball that will move in the direction I push it from, and later pull it to me based on where the player is standing.
using UnityEngine;
using System.Collections;
public class BallForce : MonoBehaviour {
public float thrust;
public Rigidbody rb;
// Use this for initialization
void Start () {
rb = GetComponent<Rigidbody> ();
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButton (0))
rb.AddForce (transform.forward * thrust);
}
}
This seems to work, but I'm not sure how I get it to move based on the position of the player. How would I do this?