Mouse Drop object location problem
I'm trying 2D game but I stacked. I want when I drop the object position between 0-0.33 the Object X position must be 0. But I cant do that.
using UnityEngine;
using System.Collections;
public class NewBehaviourScript1 : MonoBehaviour {
void OnMouseDrag()
{
float distance = 7;
Vector3 mousePosition = new Vector3 (Input.mousePosition.x, Input.mousePosition.y , distance);
Vector3 objPosition = Camera.main.ScreenToWorldPoint (mousePosition);
transform.position = objPosition ;
if ((transform.position.x >0) && (transform.position.x<0.33f)) {
Vector3 _tp = transform.position;
_tp.x = 0f;
transform.position = _tp;
`
`}
}
void Start () {
}
void Update () {
}
}
It's not working please help me :(
Comment