rotation asteroids et corrigé astronaute qui se tient pas debout (avant de se faire pogner par un asteroid). Reste a faire reset de son orientation quand passe état stun a idle)

This commit is contained in:
Jean-Sébastien Gervais 2016-04-08 20:34:38 -04:00
parent 2344057072
commit ba7adf42ae

View File

@ -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,6 +16,13 @@ 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
@ -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