From ba7adf42ae7d865d61ad1a9a7082e5eef6d71b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gervais?= Date: Fri, 8 Apr 2016 20:34:38 -0400 Subject: [PATCH 1/2] =?UTF-8?q?rotation=20asteroids=20et=20corrig=C3=A9=20?= =?UTF-8?q?astronaute=20qui=20se=20tient=20pas=20debout=20(avant=20de=20se?= =?UTF-8?q?=20faire=20pogner=20par=20un=20asteroid).=20=20Reste=20a=20fair?= =?UTF-8?q?e=20reset=20de=20son=20orientation=20quand=20passe=20=C3=A9tat?= =?UTF-8?q?=20stun=20a=20idle)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Asteroid.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Asteroid.cs b/Assets/Scripts/Asteroid.cs index 9e1f2dd..ad160d6 100644 --- a/Assets/Scripts/Asteroid.cs +++ b/Assets/Scripts/Asteroid.cs @@ -6,6 +6,9 @@ public class Asteroid : MonoBehaviour Vector3 center; public float speed; public float step; + public float rotationSpeed = 1.0f; + public float rotationDirection = 1.0f; + public bool RandomRotationSpeed = true; // Use this for initialization public void Start() @@ -13,7 +16,14 @@ public class Asteroid : MonoBehaviour speed = Random.Range(1.8F, 3F); // print(speed); center = new Vector3(0, 0); - } + + + if (RandomRotationSpeed) + rotationSpeed = 10 * UnityEngine.Random.Range(0.25f, 5f); + + rotationDirection = (Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f))*2 - 1); + + } // Update is called once per frame public void Update () { @@ -25,6 +35,11 @@ public class Asteroid : MonoBehaviour { step = speed * Time.deltaTime; this.transform.position = Vector3.MoveTowards(transform.position, center, step); + + + + this.transform.Rotate(new Vector3(0, 0, 1.0f), rotationDirection * rotationSpeed * Time.deltaTime); + } //collider must be set as "isTrigger" in unity for this method to work From d5ca619635f8b93aeb511724318d736f9aeb0b40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gervais?= Date: Fri, 8 Apr 2016 20:59:15 -0400 Subject: [PATCH 2/2] Background and kernel slow random rotation. --- Assets/Background.cs | 25 +++++++++++++++++++++++++ Assets/Background.cs.meta | 12 ++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 Assets/Background.cs create mode 100644 Assets/Background.cs.meta diff --git a/Assets/Background.cs b/Assets/Background.cs new file mode 100644 index 0000000..615af01 --- /dev/null +++ b/Assets/Background.cs @@ -0,0 +1,25 @@ +using UnityEngine; +using System.Collections; + +public class Background : MonoBehaviour { + + public float rotationSpeed = 1.0f; + public float rotationDirection = 1.0f; + public bool RandomRotationSpeed = true; + + // Use this for initialization + public void Start () { + + + if (RandomRotationSpeed) + rotationSpeed = 10 * UnityEngine.Random.Range(0.25f, 1f); + + rotationDirection = (Mathf.Floor(UnityEngine.Random.Range(0.0f, 1.99f)) * 2 - 1); + } + + // Update is called once per frame + public void FixedUpdate () { + + this.transform.Rotate(new Vector3(0, 0, 1.0f), rotationDirection * rotationSpeed * Time.deltaTime); + } +} diff --git a/Assets/Background.cs.meta b/Assets/Background.cs.meta new file mode 100644 index 0000000..523ee59 --- /dev/null +++ b/Assets/Background.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f0e11200b6b1f54479582f86a7d397b4 +timeCreated: 1460162938 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: