using UnityEngine; namespace Game { public class ClipFollowTarget : TimelineClipBase { private FollowTargetClip _mRealAsset; public override void OnEnter() { } public override void OnStay() { _mRealAsset = Asset as FollowTargetClip; var param = _mRealAsset.template; var followTarget = 0; var target = Owner.Target(); var targetEntity = Util.GetEntity(target); if (targetEntity == null) { //本身没有目标 尝试找所有者的目标 var owner = Owner.Owner(); var ownerEntity = Util.GetEntity(owner); if (ownerEntity == null) { return; } followTarget = ownerEntity.Target(); } else { followTarget = targetEntity.ID(); } var followTargetEntity = Util.GetEntity(followTarget); if (followTargetEntity == null) { return; } var dir = followTargetEntity.Pos() - Owner.Pos(); if (param.isGround) { dir = new Vector3(dir.x, 0, dir.z); } Util.EntityMove(Owner.ID(), dir); Owner.skill.CastDir = dir.normalized; } public override void OnLeave() { } } }