Unreal Engine C ++ Spawn Actor Bug

问题描述 投票:0回答:1

我有一个简单的益智游戏。

[它是多个简单游戏的组合。由于这些游戏在游戏过程中旋转,因此一切都是动态产生的。我的SpawnActor有问题。

有一个由关卡管理员(APawn)产生的名为XGame(AActor)的类。它负责为该特定X游戏生成演员。

XGame.cpp

const FVector ActorLocation = GetActorLocation();

const FVector StickLocation = FVector(0, 0, 0) + ActorLocation;
const FVector BallLocation = FVector(0, 100, 0) + ActorLocation;
const FVector CircleLocation = FVector(0, 200, 0) + ActorLocation;

UWorld* World = GetWorld();

AXStick* Stick = World->SpawnActor<AXStick>(StickLocation, FRotator(0, 0, 0));
AXBall* Ball = World->SpawnActor<AXBall>(BallLocation, FRotator(0, 0, 0));
AXCircle* Ball = World->SpawnActor<AXCircle>(CircleLocation, FRotator(0, 0, 0));

问题是,每当我生成一个演员时,其X坐标都会增加68。(我不知道为什么是68)

例如;

棒在0、0、0产生

产生的球的编号为68,100,0

圆圈在136,200,0处产生

他们都是ACharacter

如果有人可以提供帮助,我将不胜感激

c++ unreal-engine4 game-development
1个回答
0
投票

我设法通过将Stick,Ball和Circle的基类更改为AActor使其正常工作。由于Character类会自动生成胶囊组件。它们发生碰撞,并且每次生成的角色都会移动68(默认角色的胶囊移动半径为34.0)。

© www.soinside.com 2019 - 2024. All rights reserved.