UE4.9:移动字符(未设置位置)
UE4.9: Move character (not set location)
我正在从我编写的外部应用程序发送命令。此外部应用程序正在通过UDP将键盘上按下的键发送到UE4。当UE4收到消息(按下的键,例如:"w
")时,我想让角色向前走(只有1个字符)。
while (true)
{
int32 bytes_read = 0;
if (Socket->Recv(data, sizeof(data), bytes_read)){
data[bytes_read] = 0;
//Should I use this, instead of SetActorLocation?
APlayerController* playerController = World->GetFirstPlayerController();
ACharacter* myCharacter = UGameplayStatics::GetPlayerCharacter(World, 0);
FVector characterLocation = myCharacter->GetActorLocation();
FVector newCharacterLocation = characterLocation + FVector(10, 0, 0);
//This just moves the character, but does not walk and no collision is included
myCharacter->SetActorLocation(newCharacterLocation);
//FPlatformProcess::Sleep(0.1);
}
}
注意:循环正在另一个线程上执行
SetActorLocation()
在移动角色时对我不起作用,但本质上只是"传送"。我想指示角色移动,就像我在玩游戏一样,并以正常的方式控制角色。
我想通过我的外部应用程序来控制角色。我应该怎么做才能让角色移动,就像我自己在玩游戏一样,并按下,例如:"w
",向前移动?
我想明白了。。。
while (true)
{
int32 bytes_read = 0;
if (Socket->Recv(data, sizeof(data), bytes_read)){
data[bytes_read] = 0;
ACharacter* myCharacter = UGameplayStatics::GetPlayerCharacter(World, 0);
myCharacter->AddMovementInput(FVector(10, 0, 0), 5.0);
}
}
相关文章:
- 如何设置 cmake 以在不同位置查找标头和库
- OMNET++:如何在INET4.0中手动设置节点位置
- 如何在QML中设置鼠标光标位置
- 提升::P设置选项无法使所有参数都处于位置状态
- Win32 C++ 将窗口位置设置为右下角
- QT:即使在static_cast后也无法在主窗口中设置对象的位置
- 设置按钮位置
- 无法在顶点着色器中设置输入的位置
- 在 Omnet++ 中的模拟时间内更改/设置节点的新位置
- 如何在NS-3中使用Ramdomwaypoint模型时设置位置分配器
- 设置位置时QT删除对象()
- 了解现代OpenGL中的代码绘图.OBJ并设置不同的位置
- 如何获取设置位中的相对位置
- UE4.9:移动字符(未设置位置)
- 改变TextOut, c++中设置位置的单位
- 如何在二进制形式中设置位置为1或0的数
- 如何将 MATLAB 的 mex 设置定向到Microsoft Windows SDK 进行C++编译?(设置位置时出错)
- cocos2dx精灵设置位置错误
- CMake(Visual Studio)中调试和发布输出文件的设置位置
- 使用PBM_SETPOS设置位置时进度条滞后