1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using Common.Combat.FxAILogic;
- using UnityEngine;
- public class S1402_FXLogic : MonoBehaviour
- {
- public Vector3 offRotation;
- public Transform[] bodys;
- public float[] bodyDis;
- private Vector3[] defaultPos;
- Quaternion offRotationQ;
- private void Awake()
- {
- bodyDis = new float[bodys.Length];
- defaultPos = new Vector3[bodys.Length];
- defaultPos[0]=bodys[0].position;
- for (int i = 1; i < bodys.Length; i++)
- {
-
- Transform t1 = bodys[i - 1];
- Transform t2 = bodys[i];
- defaultPos[i]=t2.localPosition;
- bodyDis[i] = Vector3.Distance(t1.position, t2.position);
- }
- offRotationQ=Quaternion.Euler(offRotation);
- }
- private void OnEnable()
- {
- for (int i = 0; i < bodys.Length; i++)
- {
- bodys[i].localPosition = defaultPos[i];
- }
- }
- private void LateUpdate()
- {
- bodys[0].rotation *= Quaternion.Euler(0, 270, 0);
- for (int i = 1; i < bodys.Length; i++)
- {
- Transform t1 = bodys[i - 1];
- Transform t2 = bodys[i];
- float d = bodyDis[i];
- Vector3 dir = (t2.position - t1.position).normalized;
- Quaternion q = Quaternion.LookRotation(dir)*offRotationQ;
- t2.rotation=q;
- t2.position = t1.position + dir * d;
- }
- }
- }
|