php网站安装包制作,云南个旧建设局网站,游戏网站怎么制作,凤阳县建设局网站一.相关蓝图的练习#xff0c;在我之前的文章中射击子弹案例-CSDN博客
本篇使用C实现
1.创建C类 MyBullet,在MyBullet.h中包含相关头文件
#include CoreMinimal.h
#include GameFramework/Actor.h
#include Components/StaticMeshComponent.…一.相关蓝图的练习在我之前的文章中射击子弹案例-CSDN博客
本篇使用C实现
1.创建C类 MyBullet,在MyBullet.h中包含相关头文件
#include CoreMinimal.h
#include GameFramework/Actor.h
#include Components/StaticMeshComponent.h //模型组件
//#include Components/CapsuleComponent.h //球形碰撞组件的头文件
#include GameFramework/ProjectileMovementComponent.h //射击组件
#include Components/SphereComponent.h //球形碰撞组件的头文件
#include MyBullet.generated.h 2.声明属性变量子弹模型子弹碰撞体子弹发射器
public:UPROPERTY(VisibleAnywhere,BlueprintReadOnly,Category MyComponent)UStaticMeshComponent* BulletMesh; //static 组件UPROPERTY(VisibleAnywhere,BlueprintReadOnly,Category MyComponent)USphereComponent* MySphere; //碰撞组件UPROPERTY(VisibleAnywhere,BlueprintReadOnly,Category MyComponent)UProjectileMovementComponent* FireGunProjectile; //
3.将组件实例化
BulletMesh CreateDefaultSubobjectUStaticMeshComponent(TEXT(BulletComponent)); //实例化StaticMesh组件
//RootComponent
FireGunProjectile CreateDefaultSubobjectUProjectileMovementComponent(TEXT(FireGunProjectileComponent)); //实例化ProjectileMovement组件
MySphere CreateDefaultSubobjectUSphereComponent(TEXT(SphereCollision)); //
4.通过寻找静态模型设置静态模型的实例。设置根组件设置父子级只要Projectile在根组件后面就能让物体跟随就有发射根组件的效果。
再设置参数调整效果。发射的初始速度最大速度重力等。
MySphere CreateDefaultSubobjectUSphereComponent(TEXT(SphereCollision)); //
static ConstructorHelpers::FObjectFinderUStaticMeshTmpStaticMesh(TEXT(/Script/Engine.StaticMesh/Engine/BasicShapes/Sphere.Sphere)); //静态加载资源 重要
BulletMesh-SetStaticMesh(TmpStaticMesh.Object); //.Object重要RootComponent BulletMesh;//FireGunProjectile-setupattack
MySphere-SetupAttachment(RootComponent);
MySphere-InitSphereRadius(67);
FireGunProjectile-SetUpdatedComponent(RootComponent);//
FireGunProjectile-InitialSpeed 1200.0f;//初始速度
FireGunProjectile-MaxSpeed 24000.0f; //最大速度
FireGunProjectile-bRotationFollowsVelocity false; //旋转跟随重力
FireGunProjectile-bIsHomingProjectile true; //跟随组件
FireGunProjectile-ProjectileGravityScale 0.02; //设置重力
5.生成蓝图类放到场景中这样就能实现单发的子弹效果