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

dwcc2017怎么做网站百度推广竞价是什么意思

dwcc2017怎么做网站,百度推广竞价是什么意思,购物网站 后台模板,流量网站应该怎么做TP_WeaponComponent.h 看看头文件 暴露了attach weapon和fire给蓝图 这两个函数意义一看名字吧,就是捡起来枪的时候执行,一个就是发射子弹的时候执行 #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.h"class AFirstPersonCharacter;UCLASS(Blueprintable, BlueprintType, ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class FIRSTPERSON_API UTP_WeaponComponent : public USkeletalMeshComponent
{GENERATED_BODY()public:/** Projectile class to spawn */UPROPERTY(EditDefaultsOnly, Category=Projectile)TSubclassOf<class AFirstPersonProjectile> ProjectileClass;/** Sound to play each time we fire */UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Gameplay)USoundBase* FireSound;/** AnimMontage to play each time we fire */UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Gameplay)UAnimMontage* FireAnimation;/** Gun muzzle's offset from the characters location */UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=Gameplay)FVector MuzzleOffset;/** MappingContext */UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))class UInputMappingContext* FireMappingContext;/** Fire Input Action */UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Input, meta=(AllowPrivateAccess = "true"))class UInputAction* FireAction;/** Sets default values for this component's properties */UTP_WeaponComponent();/** Attaches the actor to a FirstPersonCharacter */UFUNCTION(BlueprintCallable, Category="Weapon")bool AttachWeapon(AFirstPersonCharacter* TargetCharacter);/** Make the weapon Fire a Projectile */UFUNCTION(BlueprintCallable, Category="Weapon")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().FindItemByClass<UTP_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 = Cast<APlayerController>(Character->GetController())){if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(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 = Cast<UEnhancedInputComponent>(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 = Cast<APlayerController>(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->SpawnActor<AFirstPersonProjectile>(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.yayakq.cn/news/709795/

相关文章:

  • 天津微网站建设装饰设计效果图
  • 张家界建设网站免费网站推荐软件
  • 表情制作器网站优化预算
  • 网站开发四个重点动漫设计与制作课程有哪些
  • 六安网站制作人才招聘上海到北京的机票
  • 承德网站制作公司优选网十科技社交媒体市场营销
  • wordpress 微网站手机网站建设电话咨询
  • 做网站哪家好什么是网络设计制作
  • 网站icp备案代理网站响应式和电脑手机
  • 商城网站建设包括哪些泰州网页设计需要多少钱
  • 哈尔滨建站怎么做美食网站怎样做蛋挞
  • 制作微信的网站公司建设网站需要固定ip吗
  • 网站建设发展网站文章怎么做才能被快速收录
  • 做网站分类模块的设计思路tplink域名申请
  • 如何创建一个国外免费网站广州网站开发外包公司
  • 滨江做网站海拉尔网页设计
  • 制作网站需要什么知识哪个网站上门做护肤
  • 专门做画册封面的网站做网站后端要学什么
  • 长沙网站制作主要公司网站页面怎么算
  • 怎么改网站域名分类网站推广费用多少
  • 河间做网站wordpress页面代码
  • 网站建设拿什么框架建设网站必须要服务器
  • 超值的郑州网站建设数字营销案例100例
  • 青海省住房和建设厅网站首页石嘴山北京网站建设
  • 中山企业营销型网站制作网站正在建设中 模版
  • 科技公司的网站建设费入什么科目做网站需要材料
  • 越秀网站建设推广网站制作协议书
  • 网站建设 选猴王网络wordpress justnews下载
  • 网站怎么更新文章做百度推广网站找谁好
  • 网站开发 培训丽水市莲都建设分局网站