Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class paddle : MonoBehaviour {
  5.    
  6.     float size = 1;
  7.     float screenSize = 16;
  8.    
  9.     // Update is called once per frame
  10.     void Update () {
  11.         Vector3 position = new Vector3 (Mathf.Clamp (this.transform.position.x, size / 2, screenSize - size/2),
  12.                                         this.transform.position.y,
  13.                                         this.transform.position.z);
  14.         position.x = Input.mousePosition.x / Screen.width * screenSize;
  15.         this.transform.position = position;
  16.     }
  17.    
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement