using System.Collections; using System.Collections.Generic; using UnityEngine; public class OilSpread : MonoBehaviour { // Use this for initialization void Start () { ranyou = this.gameObject; capsule = this.GetComponent(); } public bool oilSpred;//开始蔓延 /// /// 蔓延速度 /// [SerializeField] private float SpreadSpeed = 0.05f; [SerializeField] private float scale = 1.2f; void Update () { if (oilSpred) RanYouControl(); } /// /// 燃油 /// private GameObject ranyou; private float ranyouScale = 0; private void RanYouControl() { if (ranyouScale < scale-0.1f) { // CapsuleRadius(); ranyouScale += Time.deltaTime * SpreadSpeed * (scale - ranyouScale); ranyou.transform.localScale = new Vector3(ranyouScale, ranyou.transform.localScale.y, ranyouScale); } } private CapsuleCollider capsule; private void CapsuleRadius() { capsule.radius += Time.deltaTime * SpreadSpeed * (scale - ranyouScale) * 2; } }