所以我有两个功能放大枪和一个放大枪。
当播放机速度达到某一数字时,缩放将在Update()中被调用,同时也会被放大。
以下是功能:
void MakeGunFurther()
{
float refVel = 0;
float normalFOV = gunCam.fieldOfView;
gunCam.fieldOfView = Mathf.SmoothDamp(normalFOV, 55f, ref refTest, 0.1f);
}
void MakeGunCloser()
{
float refVel = 0;
gunCam.fieldOfView = Mathf.SmoothDamp(47, 55, ref refTest, 0.1f);
hasRan = false;
}
现在,我的问题是,第一个函数工作得很好,使枪平滑地缩小,但是当我需要用第二个函数再次放大它时,它马上就不像第一个函数那样顺利了。
请帮帮忙。谢谢!
发布于 2020-10-20 15:57:53
还没有机会在联合中使用Mathf.SmoothDamp,但我知道问题可能发生在哪里。
首先,您可能想要考虑在mono脚本的类级别上和下两个视点的范围。甚至可以序列化它,这样您就可以在播放模式中使用它了。
public float normalFieldOfView = 55f;
public float zoomedInFieldOfView = 47f; //If I got that correct from the script您还需要在方法外部的ref参数中跟踪Mathf.SmoothDamp的速度。这可能会被重置为一些值(可能0f),每次你完成放大和输出(没有足够的信息给你一个建议)。
private float currentZoomVelocity = 0f;第二,可能需要重写函数。
void MakeGunFurther()
{
gunCam.fieldOfView = Mathf.SmoothDamp(gunCam.fieldOfView, normalFieldOfView, ref currentZoomVelocity, 0.1f);
}
void MakeGunCloser()
{
gunCam.fieldOfView = Mathf.SmoothDamp(gunCam.fieldOfView, zoomedInFieldOfView, ref currentZoomVelocity, 0.1f);
hasRan = false;
}但是,您必须确保每次放大和缩放完成时都正确地重置currentZoomVelocity。
https://stackoverflow.com/questions/64447939
复制相似问题