Maybe somebody can help me?
Mistake: ‘Mesh’ is a private member of ‘ACharacter’
“Learning c++ by creating games with ue4” book
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "Monster.h"
#include "Runtime/Engine/Classes/Components/StaticMeshComponent.h"
#include "Runtime/Engine/Classes/Components/BoxComponent.h"
#include "Runtime/Engine/Classes/Components/PrimitiveComponent.h"
#include "MeleeWeapon.generated.h"
class AMonster;
UCLASS()
class NONAME_API AMeleeWeapon : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
AMeleeWeapon();
AMeleeWeapon(const class FObjectInitializer& PCIP);
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "MeleeWeapon")
float AttackDamage;
TArray<AActor*> ThingsHit;
bool Swinging;
AMonster *WeaponHolder;
UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite, Category= "MeleeWeapon")
UBoxComponent *ProxBox;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "MeleeWeapon")
UStaticMeshComponent *Mesh;
UFUNCTION(BlueprintNativeEvent, Category = "Collision")
void Prox( class UPrimitiveComponent* HitComp, class AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult );
void Swing();
void Rest();
};
//Monster.cpp:
#include "Monster.h"
#include "Avatar.h"
#include "Runtime/CoreUObject/Public/UObject/UObjectGlobals.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
#include "Runtime/Engine/Classes/Engine/SkeletalMeshSocket.h"
#include "Runtime/Engine/Classes/Components/StaticMeshComponent.h"
#include "MeleeWeapon.h"
// Sets default values
AMonster::AMonster()
{
// Set this character to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
void AMonster:: PostInitializeComponents()
{
Super:: PostInitializeComponents();
if(BPMeleeWeapon)
{
MeleeWeapon=GetWorld()->SpawnActor<AMeleeWeapon>(BPMeleeWeapon, FVector(),FRotator());
if(MeleeWeapon)
{
const USkeletalMeshSocket *socket=Mesh->GetSocketByName("ik_hand_rSocket"); //MISTAKE
socket->AttachActor(MeleeWeapon, Mesh ); //MISTAKE
}
}
}