Distance indicator fades out instead of disappearing
This commit is contained in:
@@ -5,14 +5,20 @@ public class DistanceIndicator : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public float multiplier;
|
public float multiplier;
|
||||||
Teo player;
|
Teo player;
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
SpriteRenderer sprite;
|
||||||
void Start()
|
float timeCreated;
|
||||||
{
|
void Start() {
|
||||||
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Teo>();
|
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Teo>();
|
||||||
|
sprite = GetComponent<SpriteRenderer>();
|
||||||
|
timeCreated = Time.fixedTime;
|
||||||
transform.localScale = new Vector3 (player.swingDistance*multiplier, player.swingDistance*multiplier, 1);
|
transform.localScale = new Vector3 (player.swingDistance*multiplier, player.swingDistance*multiplier, 1);
|
||||||
StartCoroutine("KillMyself");
|
StartCoroutine("KillMyself");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Update() {
|
||||||
|
sprite.color = new Color (1F, 1F, 1F, 0.5F-(Time.fixedTime-timeCreated));
|
||||||
|
}
|
||||||
|
|
||||||
IEnumerator KillMyself() {
|
IEnumerator KillMyself() {
|
||||||
yield return new WaitForSeconds (0.5F);
|
yield return new WaitForSeconds (0.5F);
|
||||||
Destroy(gameObject);
|
Destroy(gameObject);
|
||||||
|
|||||||
Reference in New Issue
Block a user