Help Replicating Flash Game Physics?

So following some advice on the forums, I’ve successfully made a 2D pong game and am now trying a 3D version of it.

There’s the game I’m trying to get the “physics” of.

Now it seems pretty straight forward, but here’s the issues I’m having:

  1. Getting the paddle to stay in the same position relative to the mouse. Currently I’m using…

     void Update () {
     	Vector2 mousePosition = new Vector2
     	(Input.mousePosition.x, Input.mousePosition.y);
     	myTransform.position = mousePosition;
     }
    

but that is giving me a really weird and undesired effect where the paddle stays still and the rest of the world moves around it.

The next part I’m having trouble with is figuring out how to put spin on the ball itself based on the paddle’s movement.

I have no idea how to go about doing this, but I would assume it’s possible with the standard Rigidbody functions?

Any links, code, snippets greatly appreciated!

Hey guys, I thought I’d post my solution to the issue. It seems fairly efficient and was sourced from another script I dug up on the Unity Forums.

I put a plane at the same level as the depth of the paddle, and set it’s transparency to 0 by using a transparent material. However, I’m sure just deleting the mesh renderer would work just as well.

using UnityEngine;
using System.Collections;

public class PaddleScript : MonoBehaviour {
	public GameObject projectile;
	public float depth = 10.0f;
		
	void Start ()
	{
		Screen.showCursor = false;
	}
		
	void Update ()
	{
		RaycastHit vHit = new RaycastHit();
		Ray vRay = Camera.main.ScreenPointToRay(Input.mousePosition);
		if (Physics.Raycast (vRay, out vHit, 1000)) {
			transform.position = Vector3.Slerp(transform.position,new Vector3(13,vHit.point.y,vHit.point.z),2);
				}
	}
}