mirror of
https://github.com/ConjureETS/PixelSphinx.git
synced 2026-03-24 02:20:58 +00:00
Merge branch 'master' of https://github.com/ETSConjure/PixelSphinx
This commit is contained in:
commit
71bb17694f
25
Assets/Background.cs
Normal file
25
Assets/Background.cs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
Assets/Background.cs.meta
Normal file
12
Assets/Background.cs.meta
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f0e11200b6b1f54479582f86a7d397b4
|
||||||
|
timeCreated: 1460162938
|
||||||
|
licenseType: Pro
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -6,6 +6,9 @@ public class Asteroid : MonoBehaviour
|
|||||||
Vector3 center;
|
Vector3 center;
|
||||||
public float speed;
|
public float speed;
|
||||||
public float step;
|
public float step;
|
||||||
|
public float rotationSpeed = 1.0f;
|
||||||
|
public float rotationDirection = 1.0f;
|
||||||
|
public bool RandomRotationSpeed = true;
|
||||||
|
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
public void Start()
|
public void Start()
|
||||||
@ -13,7 +16,14 @@ public class Asteroid : MonoBehaviour
|
|||||||
speed = Random.Range(1.8F, 3F);
|
speed = Random.Range(1.8F, 3F);
|
||||||
// print(speed);
|
// print(speed);
|
||||||
center = new Vector3(0, 0);
|
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
|
// Update is called once per frame
|
||||||
public void Update () {
|
public void Update () {
|
||||||
@ -25,6 +35,11 @@ public class Asteroid : MonoBehaviour
|
|||||||
{
|
{
|
||||||
step = speed * Time.deltaTime;
|
step = speed * Time.deltaTime;
|
||||||
this.transform.position = Vector3.MoveTowards(transform.position, center, step);
|
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
|
//collider must be set as "isTrigger" in unity for this method to work
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user