DragVector









How do I use Drag Vector
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: ClickAndDrag.cs Copy
11  void Update ()
12  {
13         if (!photonView.isMine)
14         {
15             return;
16         }
17
18      InputToEvent input = Camera.main.GetComponent();
19      if (input == null) return;
20         if (!following)
21         {
22             if (input.Dragging)
23             {
24                 camOnPress = this.transform.position;
25                 following = true;
26             }
27             else
28             {
29                 return;
30             }
31         }
32         else
33         {
34             if (input.Dragging)
35             {
36                 Vector3 target = camOnPress - (new Vector3(input.DragVector.x, 0, input.DragVector.y) * factor);
37                 this.transform.position = Vector3.Lerp(this.transform.position, target, Time.deltaTime*.5f);
38             }
39             else
40             {
41                 camOnPress = Vector3.zero;
42                 following = false;
43             }
44         }
45  }

DragVector 111 lượt xem

Gõ tìm kiếm nhanh...