UE 4ノート(_ジェイソンマスター)

13754 ワード

UE 4日常メモ


UE 4 C++メモ


ベースシフトを増やす(characterクラスならそうする、しゃがんだ出力).h
protected:
void MoveForward(float value);
void MoveRight(float value);
void BeginCrouch();
void EndCrouch();


.cpp
#include"Components/InputComponent.h"
#include"GameFramework/PawnMovementCompoent.h"
AGameCharacter::AGameCharacter()
{
GetMovementComponent()->GetNavAgentPropertiesRef().bCanCrouch=true;// cancrouch 
}

void AGameCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
	Super::SetupPlayerInputComponent(PlayerInputComponent);
	PlayerInputComponent->BindAction("jump", IE_Pressed, this, &AGameCharacter::Jump);//UE4 JUMP 
	PlayerInputComponent->BindAction("Crouch",IE_Pressed,this,&AGameCharacter::BeginCrouch);
	PlayerInputComponent->BindAction("Crouch", IE_Released, this, &AGameCharacter::EndCrouch);
	PlayerInputComponent->BindAxis("MoveForward",this,&AGameCharacter::MoveForward);
	PlayerInputComponent->BindAxis("MoveRight",this,&AGameCharacter::MoveRight);
	PlayerInputComponent->BindAxis("CameraX",this,&AGameCharacter::AddControllerPitchInput);//UE4 XYZ 
	PlayerInputComponent->BindAxis("CameraY",this,&AGameCharacter::AddControllerYawInput);
}
void AGameCharacter::MoveForward(float value)
{
	AddMovementInput(GetActorForwardVector()*value);
}

void AGameCharacter::MoveRight(float value)
{
	AddMovementInput(GetActorRightVector()*value);
}

void AGameCharacter::BeginCrouch()
{
	Crouch();//movement 
}

void AGameCharacter::EndCrouch()
{
	UnCrouch();//movement 
}



粒子を増やす方法、h
.h
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "weapon")//UPROPERTY ,EditDefaultsOnly ,blueprintreadonly ,category 
	class UParticleSystem*MuzzleEffect;
	

.cpp
.cpp
#include"Particles/ParticleSystem.h"
FVector MuzzleLocation = MeshComponent->GetSocketLocation(MuzzleSocketName);//SapwnEmitterAtLocation 
UGameplayStatics::SpawnEmitterAtLocation(GetWorld(), TraceEffect, MuzzleLocation);
UGameplayStatics::SpawnEmitterAttached(MuzzleEffect, MeshComponent, MuzzleSocketName);//meshComponent muzzlesocketname 



せんけいけんしゅつ
.cpp
AActor*MyOwner=GetOwner();// spawn owner self 
FVector Eyelocation;// 
FVector EyeRotation;// 
MyOwner->GetActorEyesViewPoint(Eyelocation,EyeRotation);//( actor ) 
if(GetWorld()->LineTraceSingleByChannel(Hit,Eyelocation,traceEnd,ECC_Visibility/* */,QueryParams))// , 
{
// 
}