当前位置: 首页 > news >正文

seo优化或网站编辑苏州相城网站建设

seo优化或网站编辑,苏州相城网站建设,企业网站建设申请怎么写,泰州网站建设专业团队TP_WeaponComponent.h 看看头文件 暴露了attach weapon和fire给蓝图 这两个函数意义一看名字吧#xff0c;就是捡起来枪的时候执行#xff0c;一个就是发射子弹的时候执行 #pragma once#include CoreMinimal.h #include Components/SkeletalMeshComponen…TP_WeaponComponent.h 看看头文件 暴露了attach weapon和fire给蓝图 这两个函数意义一看名字吧就是捡起来枪的时候执行一个就是发射子弹的时候执行 #pragma once#include CoreMinimal.h #include Components/SkeletalMeshComponent.h #include TP_WeaponComponent.generated.hclass AFirstPersonCharacter;UCLASS(Blueprintable, BlueprintType, ClassGroup(Custom), meta(BlueprintSpawnableComponent) ) class FIRSTPERSON_API UTP_WeaponComponent : public USkeletalMeshComponent {GENERATED_BODY()public:/** Projectile class to spawn */UPROPERTY(EditDefaultsOnly, CategoryProjectile)TSubclassOfclass AFirstPersonProjectile ProjectileClass;/** Sound to play each time we fire */UPROPERTY(EditAnywhere, BlueprintReadWrite, CategoryGameplay)USoundBase* FireSound;/** AnimMontage to play each time we fire */UPROPERTY(EditAnywhere, BlueprintReadWrite, Category Gameplay)UAnimMontage* FireAnimation;/** Gun muzzles offset from the characters location */UPROPERTY(EditAnywhere, BlueprintReadWrite, CategoryGameplay)FVector MuzzleOffset;/** MappingContext */UPROPERTY(EditAnywhere, BlueprintReadOnly, CategoryInput, meta(AllowPrivateAccess true))class UInputMappingContext* FireMappingContext;/** Fire Input Action */UPROPERTY(EditAnywhere, BlueprintReadOnly, CategoryInput, meta(AllowPrivateAccess true))class UInputAction* FireAction;/** Sets default values for this components properties */UTP_WeaponComponent();/** Attaches the actor to a FirstPersonCharacter */UFUNCTION(BlueprintCallable, CategoryWeapon)bool AttachWeapon(AFirstPersonCharacter* TargetCharacter);/** Make the weapon Fire a Projectile */UFUNCTION(BlueprintCallable, CategoryWeapon)void Fire();protected:/** Ends gameplay for this component. */UFUNCTION()virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;private:/** The Character holding this weapon*/AFirstPersonCharacter* Character; };看看具体实现 这个是attach 传入character然后获取到USkeletalMeshComponent就是mesh1p这个 然后就attach上去这个rule后面再细了解吧 然后character还要AddInstanceComponent(this) 这里注意attach和add是分开的 完事就可以注册mapping和bindaction了最后endplay的时候remove掉 bool UTP_WeaponComponent::AttachWeapon(AFirstPersonCharacter* TargetCharacter) {Character TargetCharacter;// Check that the character is valid, and has no weapon component yetif (Character nullptr || Character-GetInstanceComponents().FindItemByClassUTP_WeaponComponent()){return false;}// Attach the weapon to the First Person CharacterFAttachmentTransformRules AttachmentRules(EAttachmentRule::SnapToTarget, true);AttachToComponent(Character-GetMesh1P(), AttachmentRules, FName(TEXT(GripPoint)));// add the weapon as an instance component to the characterCharacter-AddInstanceComponent(this);// Set up action bindingsif (APlayerController* PlayerController CastAPlayerController(Character-GetController())){if (UEnhancedInputLocalPlayerSubsystem* Subsystem ULocalPlayer::GetSubsystemUEnhancedInputLocalPlayerSubsystem(PlayerController-GetLocalPlayer())){// Set the priority of the mapping to 1, so that it overrides the Jump action with the Fire action when using touch inputSubsystem-AddMappingContext(FireMappingContext, 1);}if (UEnhancedInputComponent* EnhancedInputComponent CastUEnhancedInputComponent(PlayerController-InputComponent)){// FireEnhancedInputComponent-BindAction(FireAction, ETriggerEvent::Triggered, this, UTP_WeaponComponent::Fire);}}return true; }再看另外一个fire函数 void UTP_WeaponComponent::Fire() {if (Character nullptr || Character-GetController() nullptr){return;}// Try and fire a projectileif (ProjectileClass ! nullptr){UWorld* const World GetWorld();if (World ! nullptr){APlayerController* PlayerController CastAPlayerController(Character-GetController());const FRotator SpawnRotation PlayerController-PlayerCameraManager-GetCameraRotation();// MuzzleOffset is in camera space, so transform it to world space before offsetting from the character location to find the final muzzle positionconst FVector SpawnLocation GetOwner()-GetActorLocation() SpawnRotation.RotateVector(MuzzleOffset);//Set Spawn Collision Handling OverrideFActorSpawnParameters ActorSpawnParams;ActorSpawnParams.SpawnCollisionHandlingOverride ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButDontSpawnIfColliding;// Spawn the projectile at the muzzleWorld-SpawnActorAFirstPersonProjectile(ProjectileClass, SpawnLocation, SpawnRotation, ActorSpawnParams);}}// Try and play the sound if specifiedif (FireSound ! nullptr){UGameplayStatics::PlaySoundAtLocation(this, FireSound, Character-GetActorLocation());}// Try and play a firing animation if specifiedif (FireAnimation ! nullptr){// Get the animation object for the arms meshUAnimInstance* AnimInstance Character-GetMesh1P()-GetAnimInstance();if (AnimInstance ! nullptr){AnimInstance-Montage_Play(FireAnimation, 1.f);}} }如果有character也有子弹类projectileclass 拿到world然后spawnActor了一个AFirstPersonProjectile就是那个子弹上一章说过这个对象他创建完毕是具备一个初速度的所以就实现发射了然后执行音频播放和动画播放动画应该是后坐力 这个attach的具体地方如下所示所以顺道看看pickup 这个是property且参数用的是这样的所以逻辑在蓝图里实现具体就是上面的图 看看cpp文件实现 就是给overlap也就是相交事件绑定一个broadcast(Character)可以触发onPickUp 然后就走蓝图里的流程了 总结 weapon实现attach然后是pickup component的mesh使用gun等character碰到gun了就触发onpick 调用attach attach后character就有一个枪拿在手里了 鼠标点击就能出发fire函数了就生成sphere飞出去
http://www.dnsts.com.cn/news/121650.html

相关文章:

  • 门户网站源码石家庄限号
  • 网站套餐表格模板小企业想做网站推广找哪家强
  • 哪个公司网络最好seo具体seo怎么优化
  • 宁波淘宝网站建设龙华区住房和建设局网站官网
  • 遵义做什么网站好司法局门户网站建设该报告
  • 企业做网站天津wordpress nofollow标签
  • 数字网站怎么建设东营胡瑞琦
  • 沈阳网站推广优化排名公司discuz怎么做h5网站
  • 如何搜索易思cms做的网站品牌型网站的设计
  • 模仿网站 素材哪里来做传奇网站
  • 网站页面设计报价表建wiki网站
  • 建立网站卖没有版权的电子书设计咨询有限公司
  • 河南科技园网站建设荷塘网站建设
  • 长沙做网站好的公司有哪些网站建设与管理心得
  • 广州车陂网站建设公司深圳市建设执业培训中心网站
  • 网站加速器厦门软件开发培训机构
  • 中国最大的建站网站红色页面网站
  • php网站开发薪资做网站得多长时间
  • 做网站的没有进项票怎么办wordpress apache2
  • 招投标网站的建设制作电商网站开发 参考文献
  • 卓成建设集团有限公司网站二手房发布网站怎么做
  • 网站建设是系统工程wordpress域名重复
  • 天津建站软件网站恶意刷新
  • 张家港建设局门户网站网站做商业计划书吗
  • 贵州企业网站建设案例成都建设网上办事大厅
  • 商丘网站设计房地产市场发展趋势
  • 想学网站建设与设计的书籍免费公司网站设计
  • 网站开发 activex做网站怎么打空格
  • 毕设代做网站餐饮网站建设教程
  • 上海网页设计公司选择兴田德润搜索引擎seo关键词优化效果