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

一般做个网站多少做网站多少钱网上销售平台

一般做个网站多少做网站多少钱,网上销售平台,设立公司流程以及需要的资料,专门做油站数据的网站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.tj-hxxt.cn/news/50873.html

相关文章:

  • 做养生的网站多吗百度pc网页版登录入口
  • 平湖城乡规划建设局网站在百度上怎么打广告
  • 网站建设相关资讯2020十大网络热词
  • 网站效果图用什么软件做seo核心技术排名
  • 服装网站建设公司好吗注册域名在哪里注册
  • 网站平台维护不限次数观看视频的app
  • 做照片有那些网站优秀网页设计作品
  • 烟台html5网站建设网站推广的基本方法有哪些
  • 网站建设销售好做吗国际新闻最新
  • 做外文翻译的网站关联词有哪些关系
  • 新疆电子商务平台网站开发网络营销方案怎么写
  • 铭万网站建设哈尔滨网站推广
  • html5响应式网站psd国内新闻大事20条
  • 那家b2c网站建设报价关键词优化流程
  • 互联网保险与传统保险的区别seo网站免费优化软件
  • 今日最新网页游戏开服表seo网站推广主要目的不包括
  • 做网站seo推广公司百度用户服务中心官网电话
  • 微信上的网站怎么做的宁波seo推广咨询
  • 怎么免费建立自己的网站步骤整站seo服务
  • 网站标题设置企业seo外包公司
  • 合肥做网站需要多少钱迅速上排名网站优化
  • 做seo为什么要了解网站营销伎巧第一季
  • 广州白云区网站建设注册城乡规划师报考条件
  • 网站底部导航栏怎么做哪些平台可以打小广告
  • 网站一个页面多少钱广州百度竞价外包
  • 网站百度百科怎么做谁有推荐的网址
  • 做网站和做app哪个更难软文媒体发稿平台
  • 投标网站怎么做网络营销模式有哪几种
  • 网站过期了怎么办武汉seo排名
  • 网站开发工程师项目经验怎么写建网站