- 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
![](https://koobas.hobune.stream/wayback/20220612175500im_/https://answers.unity.com/themes/thub/images/avi.jpg)
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