Air Hockey Game mouse drag or follow

Hi, I´m basically new in unity and I´m working in a Air Hockey Game. I just Started to play with the Bouncy Material, The objects´ masses and stuff. But now I want the Paddle to move following the mouse moves or at least that I can drag it… and it´s resulting kind of imposibble to me… Please any help on this code??

I haven’t experimented with doing something like this with a RigidBody. So that may change the solution entirely. RigidBody would require the use of adjusting your Drag and using AddForce to push the paddle in the direction of the mouse cursor.

Working this like a Pong controller you can do the following:

  1. Translate mouse cursor for the camera into a ray using Camera.ScreenPointToRay()
  2. Perform a Raycast to hit your playing surface, giving you a point your players want the paddle to move to
  3. In the Update move the paddle toward the target point

Here’s an example (may not be the best, but it’s an idea):

using UnityEngine;
using System.Collections;

public class PaddleController : MonoBehaviour {

	private LayerMask tableLayer;
	private Vector3 targetPoint;
	public float inputPadding = 0.0f;
	public float inputSpeed = 2.0f;

	// Use this for initialization
	void Start () {
		tableLayer = 1 << LayerMask.NameToLayer("Table");
	// Update is called once per frame
	void FixedUpdate () {
		Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
		RaycastHit hit;

		if (Physics.Raycast(mouseRay, out hit, tableLayer)) {
			targetPoint = hit.point;

	void Update() {
		if (Vector3.Distance(transform.position, targetPoint) > inputPadding) {
			Vector3 pos = Vector3.Lerp(transform.position, targetPoint, Time.deltaTime * inputSpeed);
			transform.position = new Vector3(pos.x, transform.position.y, pos.z);