12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.AI;
- public class DropEffectNode : MonoBehaviour
- {
- public Transform dropObj;
- bool _isStop = false;
- float desTime = 2;
- // Start is called before the first frame update
- void Start()
- {
-
- }
- // Update is called once per frame
- void FixedUpdate()
- {
- desTime -= Time.deltaTime;
- if(desTime <= 0)
- {
- Destroy(this.transform.parent.gameObject);
- }
- if (_isStop)
- {
- return;
- }
- if(dropObj)
- {
- dropObj.transform.position = this.transform.position;
- NavMeshHit hit;
- NavMesh.SamplePosition(dropObj.transform.position, out hit, 4, 1);
- }
- }
- public void SetDropItem(Transform item)
- {
- dropObj = item;
- }
- public void Stop()
- {
- _isStop = true;
- }
- }
|