void Start() { thrusterLeft = CreateThruster(thrusterLeftMount); thrusterRight = CreateThruster(thrusterRightMount); thrusterProto.SetActive(false); lifeSpan = lifeSpanMax; // add death state eventDeath += () => { eventEatFood = null; rb.velocity = Vector2.zero; rb.angularVelocity = 0.0f; thrusterLeft.gameObject.SetActive(false); thrusterRight.gameObject.SetActive(false); GetComponent <BoxCollider2D>().enabled = false; GetComponent <SpriteRenderer>().color = Color.gray; this.StopAndNullify(ref threadMoving); }; threadMoving = StartCoroutine(HandleMovement()); }
void Start() { thrusterLeft = CreateThruster(thrusterLeftMount); thrusterRight = CreateThruster(thrusterRightMount); thrusterProto.SetActive(false); Reset(); }
CreatureThruster CreateThruster(Transform parent) { var thrusterObj = GameObject.Instantiate(thrusterProto); thrusterObj.transform.SetParent(parent, false); thrusterObj.transform.localPosition = Vector3.zero; thrusterObj.transform.localRotation = Quaternion.identity; CreatureThruster thruster = thrusterObj.GetComponent <CreatureThruster>(); return(thruster); }