- Home /
Freeze movement only in one axis
Hi I got stuck in this code problem,can someone show how to make it move only in one axis, this code is based to drag a ball like a game called rolling sky,.Code below.
public float distance = 10f;
void OnMouseDrag(){
Vector 3 mouseposition = new Vector3(Input.mouseposition.x, Input.mousposition.y, distance);
Vector3 ballPosition = Camera.main.ScreenToWorldPoint(mouseposition);
transform.position = ballPosition;
}
Comment
Your answer
Follow this Question
Related Questions
Strange touch behavior 0 Answers
Camera momentum after lifting finger 0 Answers
Creating a matrix or some sort. 1 Answer
how can i create a finger trail 1 Answer
Converting Simple Web game to Iphone 2 Answers