You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
751 B

  1. using UnityEngine;
  2. using System.Collections;
  3. public class ThrusterOriginal : MonoBehaviour {
  4. public float speed;
  5. private ParticleSystem particles;
  6. [HideInInspector]
  7. public Rigidbody2D rigid;
  8. // Use this for initialization
  9. void Start() {
  10. rigid = GetComponent<Rigidbody2D>();
  11. particles = GetComponentInChildren<ParticleSystem>();
  12. particles.enableEmission = false;
  13. }
  14. // Update is called once per frame
  15. void FixedUpdate() {
  16. if (Input.anyKey) {
  17. rigid.AddForceAtPosition(transform.right * speed, transform.position, ForceMode2D.Impulse);
  18. particles.enableEmission = true;
  19. } else {
  20. particles.enableEmission = false;
  21. }
  22. }
  23. }