C# Cinemachine 2D isn';在复活玩家后,t跟随

C# Cinemachine 2D isn';在复活玩家后,t跟随,c#,unity3d,cinemachine,C#,Unity3d,Cinemachine,我曾试图让Cinemachine跟随我的播放器,即使在重生之后,但它不起作用,老实说,我不知道还能做什么。我不想为照相机编写新的代码,因为Cinemachine有很多好的特性 我在想,我可以重新设置变量,这样Cinemachine就可以继续使用同一个对象,而不是破坏这个对象,但是我对编码还比较陌生,所以我不知道怎么做 这是玩家代码: 使用系统集合; 使用System.Collections.Generic; 使用UnityEngine; 使用电影机; 公共阶层死亡:单一行为 { 公众静态死亡;

我曾试图让Cinemachine跟随我的播放器,即使在重生之后,但它不起作用,老实说,我不知道还能做什么。我不想为照相机编写新的代码,因为Cinemachine有很多好的特性

我在想,我可以重新设置变量,这样Cinemachine就可以继续使用同一个对象,而不是破坏这个对象,但是我对编码还比较陌生,所以我不知道怎么做

这是玩家代码:

使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
使用电影机;
公共阶层死亡:单一行为
{
公众静态死亡;
公共电影机虚拟电影机;
void Start()
{    
如果(死亡==null)
{    
death=GameObject.FindGameObjectWithTag(“死亡”).GetComponent();
}
myCinemachine=GetComponent();
}
公共图书馆;
公众改造重生;
公共无效重新授权玩家()
{
var sprownedplayer=实例化(playerPrefab,respawn.position,respawn.rotation);
Log(“TODO添加繁殖粒子”);
myCinemachine.m_Follow=派生播放器;
}
公共静态无效玩家(玩家)
{
销毁(玩家。游戏对象);
死亡。重生玩家();
}    
}
这是死亡密码:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Death : MonoBehaviour
{
    public static Death death;

    void Start()
    {
        if (death == null)
        {
            death = GameObject.FindGameObjectWithTag("Death").GetComponent<Death>();
        }

    }

    public Transform playerPrefab;
    public Transform respawn;

    public void RespawnPlayer()
    {
        var spawnedPlayer = Instantiate(playerPrefab, respawn.position, respawn.rotation);
        Debug.Log("TODO Add Spawn Particles");

    }

    public static void KillPlayer (Player player)
    {
        Destroy(player.gameObject);
        death.RespawnPlayer();
    }

}
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
公共阶层死亡:单一行为
{
公众静态死亡;
void Start()
{
如果(死亡==null)
{
death=GameObject.FindGameObjectWithTag(“死亡”).GetComponent();
}
}
公共图书馆;
公众改造重生;
公共无效重新授权玩家()
{
var sprownedplayer=实例化(playerPrefab,respawn.position,respawn.rotation);
Log(“TODO添加繁殖粒子”);
}
公共静态无效玩家(玩家)
{
销毁(玩家。游戏对象);
死亡。重生玩家();
}
}

比如,你在《死亡》中对相机做了其他什么吗?我做了。我试着让它跟随克隆人,但它不起作用,我不知道还有什么好做的,不管你死后改变了什么,你都需要撤销..完成了。我在死亡代码中删除了所有与Cinemachine相连的内容。除了尝试重生之外,我看不到您最初在何处分配相机。也看不到你叫KillPlayer的地方。你
Destroy(player.gameObject)但我看不到您为您的玩家对象分配任何其他内容。我猜你在某处跟踪
播放器
。直到你杀死玩家并重生。我认为这里没有足够的信息来正确解决这个问题,因为有些代码丢失了。-另外,玩家代码和死亡代码看起来几乎一样。。。。。。。