Пример #1
0
    //生产函数(工厂模式)
    public static FollowPlayerAction GetSSAction(float distanceAway, float distanceUp, float speed)
    {
        FollowPlayerAction action = ScriptableObject.CreateInstance <FollowPlayerAction>();

        action.distanceAway = distanceAway;
        action.distanceUp   = distanceUp;
        action.speed        = speed;
        return(action);
    }
Пример #2
0
    //跟随玩家
    public void FollowPlayer(GameObject follower, float distanceAway, float distanceUp, float speed)
    {
        FollowManager followManager = follower.GetComponent <FollowManager>();

        if (followManager == null)
        {
            return;
        }
        if (!followManager.followable)
        {
            followManager.followable = true;
            follow = FollowPlayerAction.GetSSAction(distanceAway, distanceUp, speed);
            RunAction(follower, follow, this);
        }
    }