Skip to content

Instantly share code, notes, and snippets.

@AkshatGiri
Created June 20, 2016 23:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkshatGiri/25fc81380d3feb208503226787e48ffb to your computer and use it in GitHub Desktop.
Save AkshatGiri/25fc81380d3feb208503226787e48ffb to your computer and use it in GitHub Desktop.
Paddle glitching problem
using UnityEngine;
using System.Collections;
public class Paddle : MonoBehaviour
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
Vector3 paddlePos = new Vector3(0.5f, transform.position.y, 0f);
float mousePosInBlocks = Input.mousePosition.x / Screen.width * 16;
paddlePos.x = Mathf.Clamp(mousePosInBlocks, 0.5f, 15.5f );
this.transform.position = paddlePos;
print(Input.mousePosition.x);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment