我正在做一个太空侧滚动游戏的项目,我试图让引擎的相机表现得像一个古老的太空射击游戏(单独移动,当玩家的棋子空闲时,将它独自移动到边缘),我试图找到宇宙飞船控制器的教程,但我只找到了地面单位的相机选项。
发布于 2013-07-12 23:49:59
我的解决方案是覆盖默认的虚幻相机,并编写你自己的程序。这里有一个关于如何实现这一点的快速指南。这很简单,真的。
第一步是创建您的自定义Camera类。这里:
class MyCustomCamera extends Camera;
//Camera variables
var Vector mCameraPosition;
var Rotator mCameraOrientation;
var float mCustomFOV;
/**Init function of the camera
*/
function InitializeFor(PlayerController PC)
{
Super.InitializeFor(PC);
mCameraPosition = Vect(0,0,0);
//Etc...
}
/**Update function of the camera
*/
function UpdateViewTarget(out TViewTarget OutVT, float DeltaTime)
{
//This is the meat of the code, here you can set the camera position at each
//frame, it's orientation and FOV if need be (or anything else really)
OutVT.POV.Location = mCameraPosition;
OutVT.POV.Rotation = mCameraOrientation;
OutVT.POV.FOV = mCustomFOV;
}下一步也是最后一步是将新的自定义相机设置为默认相机。为此,在PlayerController类中添加以下defaultproperties块:
CameraClass=class'MyCustomCamera'现在,对于您对“滚动”相机的特定需求,您可以在更新函数中执行以下简单操作:
/**Update function of the camera
*/
function UpdateViewTarget(out TViewTarget OutVT, float DeltaTime)
{
//This is the meat of the code, here you can set the camera position at each
//frame, it's orientation and FOV if need be (or anything else really)
//This will make your camera move on the X axis at speed 50 units per second.
mCameraPosition += Vect(50*DeltaTime,0,0);
OutVT.POV.Location = mCameraPosition;
OutVT.POV.Rotation = mCameraOrientation;
OutVT.POV.FOV = mCustomFOV;
}希望这篇文章能帮你入门!
https://stackoverflow.com/questions/17581925
复制相似问题