RotateAround
How do I use Rotate Around
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
Line | Code | Ex.. |
---|---|---|
59 | transform.RotateAround(rotationPoint, this.rotateDirection, rotateBy); | 1 |
162 | transform.RotateAround(rotationPoint, this.rotateDirection, rotateBy); | 2 |
File name: BlockScript.cs
Copy
42 void Update () {
43
44 if (moveStartTime >= 0F) {
45 float percentComplete = (Time.time - this.moveStartTime) / this.moveDuration;
46 if(this.blockNumber > -1) {
47 transform.position = Vector3.Lerp(this.originalPosition, this.moveNewPosition, percentComplete);
48 }
49 if (percentComplete >= 1F) {
50 this.moveStartTime = -1F;
51 this.setBlockNumber(this.moveNewBlockNumber);
52 transform.position = this.originalPosition;
53 }
54 }
55
56 if (this.rotationTotal >= 0F) {
57 float rotateBy = 90 * Time.deltaTime / this.moveDuration;
58 Vector3 rotationPoint = new Vector3 (3f, 4f, 3f);
59 transform.RotateAround(rotationPoint, this.rotateDirection, rotateBy);
60 this.rotationTotal += rotateBy;
61
62 if(rotationTotal >= 90) {
63 Debug.Log (rotationTotal);
64 this.rotationTotal = -1F;
65 transform.position = this.originalPosition;
66 transform.rotation = new Quaternion(0,0,0,1);
67 this.setBlockNumber(rotateNewBlockNumber);
68 }
69 }
70 }
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
156 this.GetComponent
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 }
RotateAround 159 lượt xem
Gõ tìm kiếm nhanh...