ue4中模式设定
来源:互联网 发布:office2016激活软件 编辑:程序博客网 时间:2024/05/16 19:15
1、以观察者的视角(Spectator)
那么在Word Setting中Default Pawn和Spectator两者要设置为同一个类
class AMySpectator : public ASpectatorPawn
{
GENERATED_BODY()
public:
AMySpectator();
virtual ~AMySpectator();
// Begin ADefaultPawn interface 重写这几个方法
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
virtual void MoveForward(float Val) override;
virtual void MoveRight(float Val) override;
// End ADefaultPawn interface
实现部分
void AMySpectator::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
Super::SetupPlayerInputComponent(InputComponent);
check(InputComponent);
InputComponent->BindAction("ZoomOut", IE_Pressed, this, &AMySpectator::OnMouseScrollUp);
InputComponent->BindAction("ZoomIn", IE_Pressed, this, &AMySpectator::OnMouseScrollDown);
InputComponent->BindAxis("MoveForward", this, &AMySpectator::MoveForward);
InputComponent->BindAxis("MoveRight", this, &AMySpectator::MoveRight);
}
*此处有坑
使用观察这模式下,必须 禁止 引擎去生成默认的 SpectatorPawn 。反之, 以第三人称 或 第一人称 则 不能禁止
通过重写 AGameMode的一个方法 .h
class MYSLATE_API AMyGameMode : public AGameMode
{
GENERATED_BODY()
public:
/**
* Handle new player, skips pawn spawning.
* @param NewPlayer
*/
virtual void RestartPlayer(AController* NewPlayer) override;
};
.cpp
void AMyGameMode::RestartPlayer(AController* NewPlayer)
{
AActor* const StartSpot = FindPlayerStart(NewPlayer);
if (StartSpot != nullptr)
{
// initialize and start it up
InitStartSpot(StartSpot, NewPlayer);
AMyPlayerCtrler* const NewPC = Cast<AMyPlayerCtrler>(NewPlayer);
if (NewPC != nullptr)
{
NewPC->SetInitialLocationAndRotation(StartSpot->GetActorLocation(), StartSpot->GetActorRotation());
}
}
else
{
UE_LOG(GameLogger, Warning, TEXT("Player start not found, failed to restart player"));
}
}
不然引擎会调用原有的 RestartPlayer 方法,把自定的SpectatorPawn 置空
void AGameMode::RestartPlayer(AController* NewPlayer)
NewPlayer->Possess(NewPlayer->GetPawn());
void APlayerController::ChangeState(FName NewState)
void APlayerController::EndSpectatingState()
void APlayerController::DestroySpectatorPawn()
SetSpectatorPawn(NULL);
2、以第三人称或第一人称视角
摄像机是绑定在一个实体Character上,测试Spectator Class是无效的
UCLASS()
class AMyPlayerChar : public AMyChar
{
GENERATED_BODY()
/** Top down camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* TopDownCameraComponent;
/** Camera boom positioning the camera above the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* CameraBoom;
3、c++接收不到绑定事件的原因
- 在蓝图中由对应事件的实现,必须干掉,在c++才能接收到事件
0 0
- ue4中模式设定
- UE4中窗口模式切换
- UE4 蓝图设定快捷键
- UE4 服务器模式
- UE4服务器模式
- UE4 设置窗口模式
- UE4材质渲染模式
- 终端模式设定选项
- dataGridView编辑模式设定
- UE4中集成Wiimote
- UE4中集成Wiimote
- UE4中切换关卡
- 实际开发中或产品部署中开发模式(devMode)的设定
- flash中设定焦点
- ubuntu中设定NFS
- linux的模式设定,转换
- PullToRefresh各种view模式设定
- UE4中StaticLoadClass和StaticLoadObject
- UE4容器TArray、TMap的使用
- 用Promise让Node的异步任务顺序执行
- ACL(访问控制列表)基础篇
- Vertical Histogram
- 初识ReactJS的组件化开发(八):用表单做评论 :限制textarea可输入字符长度
- ue4中模式设定
- Python 获取磁盘信息的脚本
- Smarty模板技术学习
- java可变参数
- Smarty模板技术学习(二)
- File Nesting
- 在Express中使用html (Node.js)
- InnoDB存储引擎_数据库隔离级别(二)
- 单位移动时如何启用ROV避让模式