Question by 
               Derpybunneh · May 03, 2016 at 12:50 PM · 
                c#rigidbodypositionmovingpositioning  
              
 
              How do you thrust an object to another object's position?
Hello! I'm a complete noob, and I am try to make a pong game, and I'm trying to thrust the CPU paddle to the ball's x position. I'm not trying to instantaneously set the paddle's x pos. to the ball's x pos., I'm trying to thrust the paddle to the ball's x pos. How would you do that?
I'm using C#, and so far my code is:
 using UnityEngine;
 using System.Collections;
 
 public class P2_Movement : MonoBehaviour {
 
     public float thrust;
     public Rigidbody rb;
 
     // Use this for initialization
     void Start () {
         rb = GetComponent<Rigidbody>();
     }
     
     // Update is called once per frame
     void FixedUpdate () {
         float ball_pos = GameObject.Find("Ball").transform.position.x;
         rb.AddForce(ball_pos, 0, 0, ForceMode.Impulse);
     }
 }
 
               My current code just finds the ball game object's x position, and then it thrusts my CPU paddle using the ball's x position as its speed.
How can I make it so that my CPU paddle thrusts towards the ball's x position?
               Comment
              
 
               
              Your answer