Advertisement
Guest User

Untitled

a guest
Nov 19th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Paddle : MonoBehaviour {
  6.  
  7.  
  8.     void Start () {
  9.        
  10.     }
  11.    
  12.  
  13.     void Update () {
  14.         Vector3 paddlePos = new Vector3(0.5f, this.transform.position.y, 0f);
  15.         float mousePosInBlocks = (Input.mousePosition.x / Screen.width * 16);
  16.  
  17.         paddlePos.x = Mathf.Clamp(mousePosInBlocks, 0.5f, 15.5f);
  18.  
  19.         this.transform.position = paddlePos;
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement