子弹创建及发射 Learn Unreal Engine (with C++)

子弹创建及发射 Learn Unreal Engine (with C++)

SpaceshipBattle · fanxingin/UE4项目 - 码云 - 开源中国 (gitee.com)

子弹的创建

声明:

UPROPERTY(EditAnywhere, Category = "Fire")
		TSubclassOf Bullet;

实现:

//在空组件处生产子弹
		GetWorld()->SpawnActor(Bullet, SpawnPoint->GetComponentLocation(), SpawnPoint->GetComponentRotation(), SpawnParameters);

子弹的发射

  1. 创建UProjectileMovementComponent组件,不需要attach to root component

  2. 调节UProjectileMovementComponent蓝图细节

    //运动类型组件与根组件并列不需要AttachTo RootComponent
    	ProjectileMovementComp = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileMovementComp"));
    
    子弹创建及发射 Learn Unreal Engine (with C++)_第1张图片

你可能感兴趣的:(UE4,C++,虚幻,c++,ue4)