You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			50 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C#
		
	
			
		
		
	
	
			50 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C#
		
	
| 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()
 | |
|         {
 | |
|         }
 | |
|     }
 | |
| } |