From d02d8779f4c36d4aec58a5d2d460f482894af3b8 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 4 Nov 2020 08:59:59 +0800 Subject: *after image --- .../Scripts/Effects/AfterImage/AfterImagePool.cs | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Assets/Scripts/Effects/AfterImage/AfterImagePool.cs (limited to 'Assets/Scripts/Effects/AfterImage/AfterImagePool.cs') diff --git a/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs b/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs new file mode 100644 index 00000000..f9d033fd --- /dev/null +++ b/Assets/Scripts/Effects/AfterImage/AfterImagePool.cs @@ -0,0 +1,50 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class AfterImagePool : MonoBehaviour +{ + + //public CharacterControl myCharacterControl; + public GameObject targetObject; //Set these manually to the character object you're copying + public Animator targetAnimator; //Set these manually to the character object you're copying + public GameObject prefab; //This is the prefab you made in the scene. It's a parent transform with an animator and AfterImage script on it, with Armature and SkinnedMeshRenderer children + public int poolSize = 10; + public List afterImages; + + public int interval = 10; + + public int time = 0; + + // Use this for initialization + void Start() + { + //myCharacterControl = transform.root.GetComponent(); + //Debug.Log("START AFTER IMAGE POOL"); + afterImages = new List(poolSize); + for (int i = 0; i < poolSize; i++) + { + GameObject nextAfterImage = Instantiate(prefab); + afterImages.Add(nextAfterImage.GetComponent()); + + nextAfterImage.GetComponent().targetObject = targetObject; //Game Object Target + nextAfterImage.GetComponent().targetAnimator = targetAnimator; //Animator Target + } + } + + // Update is called once per frame + void Update() + { + //if (CitadelDeep.hitPause > 0 || CitadelDeep.debugPause) { return; } + time++; + if (time > interval) { time = 0; AddAfterImage(); } + } + + void AddAfterImage() + { + for (int i = 0; i < poolSize; i++) + { + if (!afterImages[i].active) { afterImages[i].Activate(); break; } + } + } +} \ No newline at end of file -- cgit v1.1-26-g67d0