【发布时间】:2018-06-19 14:25:00
【问题描述】:
我在士兵动画师中有一个接地过渡,默认情况下从这个过渡开始。然后我在 3 秒后这样做,它会在从 Grounded 到 Rifle_Aiming_Idle 的两个过渡之间缓慢变化。
但是要查看它是如何工作的,以及它是否像我想要的那样工作得很好,我必须关闭 FPSController Camera(FPSCamera 已关闭灰色)。因此,在运行游戏时,活动摄像头是主摄像头和 CM vcam1(Cinemachine 虚拟摄像头)。
但我想用这个过场动画制作更多内容。 我希望首先,只有当 FPSController 的玩家退出门时,过场动画才会开始:
此脚本附加到 FPSController:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Playables;
public class SpaceshipCutscene : MonoBehaviour
{
public Transform player;
public Transform npc;
public float cutsceneDistance = 5f;
public float speed;
private bool moveNpc = false;
// Use this for initialization
void Start()
{
}
private void Update()
{
if (moveNpc)
{
float travel = Mathf.Abs(speed) * Time.deltaTime;
Vector3 direction = (player.position - npc.position).normalized;
Quaternion lookrotation = Quaternion.LookRotation(direction);
npc.rotation = Quaternion.Slerp(npc.rotation, lookrotation, Time.deltaTime * 5);
Vector3 position = npc.position;
position = Vector3.MoveTowards(position, player.position, travel);
npc.position = position;
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject.name == "Horizontal_Doors_Kit")
moveNpc = true;
}
}
我希望当玩家 FPSController 退出门时启动过场动画,并且在播放/执行过场动画时,我希望同时让动画师的士兵面向 FPSController 缓慢旋转。
FPSController exit the door > 士兵慢慢地从地面切换到瞄准模式,士兵慢慢地旋转面对 FPSController。
我的问题是如何在 FPSController 退出门时启动 Cinemachine 过场动画,以及如何让 Soldier(npc) 面向 FPSController 缓慢旋转。
我在脚本中的更新中尝试过的效果不佳。 它使 npc 移动并且没有像我想要的那样在过场动画中缓慢旋转。
也许对于旋转部分,我应该使用 Cinemachine 而不是在脚本中这样做?也许我也应该在这里使用 Timeline 作为旋转部分?
【问题讨论】: