ResetPosition









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

Featured Snippets


File name: ConnectorScript.cs Copy
24  public void Initialize(int x, int y, int z, string axis, GameControllerScript gameScript) {
25   this.scale = gameScript.scale;
26   this.yOffset = gameScript.yOffset;
27   this.gameScript = gameScript;
28   this.moveDuration = gameScript.moveDuration;
29   this.x = x;
30   this.y = y;
31   this.z = z;
32   this.axis = axis;
33   this.ResetPosition();
34  }
File name: ConnectorScript.cs Copy
36  private void ResetPosition() {
37
38   if (this.axis == "x") {
39    transform.position = new Vector3(
40     x * this.scale + (this.scale/2f),
41     y * this.scale + this.yOffset,
42     z * this.scale);
43    transform.eulerAngles = new Vector3(0,0,90);
44   }
45   if (this.axis == "y") {
46    transform.position = new Vector3(
47     x * this.scale,
48     y * this.scale + this.yOffset + this.scale/2f,
49     z * this.scale);
50    transform.eulerAngles = new Vector3(0,0,0);
51   }
52   if (this.axis == "z") {
53    transform.position = new Vector3(
54     x * this.scale,
55     y * this.scale + this.yOffset,
56     z * this.scale + this.scale/2f);
57    transform.eulerAngles = new Vector3(90,0,0);
58   }
59  }
File name: ConnectorScript.cs Copy
151  void Update () {
152   //this.renderer.enabled = this.show;
153   //Vector3 rotationPoint = new Vector3 (3f, 4f, 3f);
154
155   this.GetComponent().enabled = this.show();
156   this.GetComponent().material.color = this.getConnectorColor();
157
158
159   if (this.rotationTotal >= 0F) {
160    float rotateBy = 90 * Time.deltaTime / this.moveDuration;
161    Vector3 rotationPoint = new Vector3 (3f, 4f, 3f);
162    transform.RotateAround(rotationPoint, this.rotateDirection, rotateBy);
163    this.rotationTotal += rotateBy;
164
165    if(rotationTotal >= 90) {
166     this.rotationTotal = -1F;
167     this.ResetPosition ();
168    }
169   }
170  }

ResetPosition 149 lượt xem

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