子弹创建及发射 Learn Unreal Engine (with C++)
SpaceshipBattle · fanxingin/UE4项目 - 码云 - 开源中国 (gitee.com)
子弹的创建
声明:
UPROPERTY(EditAnywhere, Category = "Fire")
TSubclassOf<ABullet> Bullet;
实现:
//在空组件处生产子弹
GetWorld()->SpawnActor<ABullet>(Bullet, SpawnPoint->GetComponentLocation(), SpawnPoint->GetComponentRotation(), SpawnParameters);
子弹的发射
-
创建
UProjectileMovementComponent
组件,不需要attach to root component -
调节
UProjectileMovementComponent
蓝图细节//运动类型组件与根组件并列不需要AttachTo RootComponent ProjectileMovementComp = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComp"));