37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class Humo : MonoBehaviour, IPooledObject{
|
|
|
|
int transparencia;
|
|
float currentTrans;
|
|
float scale;
|
|
public float speed;
|
|
public float fadeSpeed;
|
|
public float scaleSpeed;
|
|
|
|
HumoLookAt lookat;
|
|
RawImage image;
|
|
|
|
// Start is called before the first frame update
|
|
public void OnObjectSpawn(){
|
|
lookat = GetComponentInParent<HumoLookAt>();
|
|
image = GetComponent<RawImage>();
|
|
transparencia = Random.Range(25, 75);
|
|
currentTrans = transparencia;
|
|
scale = Random.Range(1f, 2.5f);
|
|
transform.localScale = new Vector3(scale, scale, scale);
|
|
image.color = new Color(image.color.r, image.color.g, image.color.b, currentTrans / 255);
|
|
transform.rotation = lookat.t;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update(){
|
|
transform.Translate(Vector2.up * speed * Time.deltaTime);
|
|
currentTrans = currentTrans - fadeSpeed;
|
|
image.color = new Color(image.color.r, image.color.g, image.color.b, currentTrans / 255);
|
|
image.transform.localScale = new Vector3(scale - scaleSpeed * Time.deltaTime, scale - scaleSpeed * Time.deltaTime, scale - scaleSpeed * Time.deltaTime);
|
|
}
|
|
}
|