首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使UDK (虚幻开发工具包)的摄像头独立移动侧边滚动?

如何使UDK (虚幻开发工具包)的摄像头独立移动侧边滚动?
EN

Stack Overflow用户
提问于 2013-07-11 06:18:31
回答 1查看 2K关注 0票数 0

我正在做一个太空侧滚动游戏的项目,我试图让引擎的相机表现得像一个古老的太空射击游戏(单独移动,当玩家的棋子空闲时,将它独自移动到边缘),我试图找到宇宙飞船控制器的教程,但我只找到了地面单位的相机选项。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-07-12 23:49:59

我的解决方案是覆盖默认的虚幻相机,并编写你自己的程序。这里有一个关于如何实现这一点的快速指南。这很简单,真的。

第一步是创建您的自定义Camera类。这里:

代码语言:javascript
复制
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块:

代码语言:javascript
复制
CameraClass=class'MyCustomCamera'

现在,对于您对“滚动”相机的特定需求,您可以在更新函数中执行以下简单操作:

代码语言:javascript
复制
/**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;
}

希望这篇文章能帮你入门!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/17581925

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档