我正在进行一个太空侧滚动游戏的项目,我试图让引擎的相机表现得像一个旧的太空射击游戏(单独移动,当玩家 pawn 保持空闲时单独移动它的边缘),我试图找到宇宙飞船控制器的教程,但我只找到了陆地单位的相机选项。
问问题
2004 次
1 回答
0
我对此的解决方案是覆盖默认的虚幻相机并自己编程。这是有关如何完成此操作的快速指南。这很容易,真的。
第一步是创建您的自定义相机类。这里:
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;
}
希望这能让你开始!
于 2013-07-12T15:49:58.640 回答