Error C2065: 'UMatineeCameraShake' : undeclared identifier

I keep getting Error C2065: ‘UMatineeCameraShake’ : undeclared identifier in the ProjectileBase.h and Pawnbase.h file in the second last lesson for the tank section. I looked in the github for the code, copied and pasted it, and still nothing.

UPROPERTY(EditAnywhere, Category = "Effects")
TSubclassOf<UMatineeCameraShake> HitShake;
GetWorld()->GetFirstPlayerController()->ClientPlayCameraShake(HitShake);

I tried including the CameraShake files directly in multiple ways, but that did not work either. I refreshed my code and I also restarted unreal, but to no avail.

The only difference that I can see is my version of UE: 4.27- not .25 or .26. Is there a change here that is not covered?

You would need to forward declare it and then include it in the cpp however 4.27 moved that class to a different module. I suggest you go for the easier path and just use UCameraShakeBase instead, you can still use the matinee one to derive the BP from.

1 Like

Just to see if I understand you correctly:

The path you are suggesting is that I replace my UMatineeCameraShake that is attached to the TSubclass<>, with UCameraShakeBase and keep everything else I have the same? Or are you saying that I should make my BP the UCameraShakeBase, and my code will be fine as is?

With the forward declare, I would have to add class UMatineeCameraShake, and then include this in my cpp as well?

Yes. This one.

1 Like

I seem to get this error code when I change out my UMatineeCameraShake with the UCameraShakeBase in the TSubclassOf<>:

   C:\UnrealProjects\ToonTanks\Toontanks\Intermediate\Build\Win64\UE4Editor\Inc\ToonTanks\PawnBase.gen.cpp(28) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
   C:\UnrealProjects\ToonTanks\Toontanks\Source\ToonTanks\Pawns\PawnBase.cpp(115) : error C2664: 'void APlayerController::ClientStartCameraShake(TSubclassOf<UCameraShakeBase>,float,ECameraShakePlaySpace,FRotator)': cannot convert argument 1 from 'TSubclassOf<UMatineeCameraShake>' to 'TSubclassOf<UCameraShakeBase>'
  C:\UnrealProjects\ToonTanks\Toontanks\Source\ToonTanks\Pawns\PawnBase.cpp(115): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
  C:\Program Files\Epic Games\UE_4.27\Engine\Source\Runtime\Engine\Classes\GameFramework/PlayerController.h(902): note: see declaration of 'APlayerController::ClientStartCameraShake'
  [2/8] PawnBase.gen.cpp

That is basically saying you’re still using UMatineeCameraShake and that you probably aren’t forward declaring whatever you’re using in the header. Could your show your code?

1 Like

That is what I was wondering. It was talking about using something that does not belong to the class.

Here it is cleaned up of my messy notes, hopefully I didn’t delete anything in the process:

ProjectileBase.h

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "ProjectileBase.generated.h"

class UProjectileMovementComponent;

UCLASS()
class TOONTANKS_API AProjectileBase : public AActor
{
	GENERATED_BODY()
	
private: 
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))	
	UProjectileMovementComponent* ProjectileMovement;
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))	
	UStaticMeshComponent* ProjectileMesh;
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Components", meta = (AllowPrivateAccess = "true"))	
	UParticleSystemComponent* ParticleTrail;

	UPROPERTY(EditDefaultsOnly, Category = "Damage")
	TSubclassOf<UDamageType> DamageType;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Move", meta = (AllowPrivateAccess = "true"))
	float MovementSpeed = 1300;
	UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Damage", meta = (AllowPrivateAccess = "true"))
	float Damage = 50;
	UPROPERTY(EditAnywhere, Category = "Effects")
	UParticleSystem* HitParticle;
	UPROPERTY(EditAnywhere, Category = "Effects")
	USoundBase* HitSound;
	UPROPERTY(EditAnywhere, Category = "Effects")
	USoundBase* LaunchSound;
	UPROPERTY(EditAnywhere, Category = "Effects")
	TSubclassOf<UCameraShakeBase> HitShake;

	UFUNCTION()
	void OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit);

public:	

	AProjectileBase();

protected:
	virtual void BeginPlay() override;
};

ProjectileBase.cpp

#include "ProjectileBase.h"
#include "Components/StaticMeshComponent.h"
#include "GameFramework/ProjectileMovementComponent.h"
#include "Kismet/GameplayStatics.h"
#include "Particles/ParticleSystemComponent.h"


AProjectileBase::AProjectileBase()
{
	PrimaryActorTick.bCanEverTick = false;

	ProjectileMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Projectile Mesh"));//Visual

	RootComponent = ProjectileMesh;

	ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("Projectile Movement"));


	ProjectileMovement->InitialSpeed = MovementSpeed;
	ProjectileMovement->MaxSpeed = MovementSpeed;

	ParticleTrail = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("Partical Trial"));
	ParticleTrail->SetupAttachment(RootComponent);	

	InitialLifeSpan = 3.0f;

}

void AProjectileBase::BeginPlay()
{
	Super::BeginPlay();	

	ProjectileMesh->OnComponentHit.AddDynamic(this, &AProjectileBase::OnHit);

	UGameplayStatics::PlaySoundAtLocation(this, LaunchSound, GetActorLocation());
	
}

void AProjectileBase::OnHit(UPrimitiveComponent* HitComp, AActor* OtherActor, UPrimitiveComponent* OtherComp, FVector NormalImpulse, const FHitResult& Hit)

{
	AActor* MyOwner = GetOwner();
	if(!MyOwner){return;}
	
	if (OtherActor && OtherActor != this && OtherActor != MyOwner)
	{
		UGameplayStatics::ApplyDamage(
			OtherActor, 
			Damage,
			MyOwner->GetInstigatorController(),
			this,
			DamageType
			);

		UGameplayStatics::SpawnEmitterAtLocation(this, HitParticle, GetActorLocation());

		UGameplayStatics::PlaySoundAtLocation(this, HitSound, GetActorLocation());

		GetWorld()->GetFirstPlayerController()->ClientStartCameraShake(HitShake);

		Destroy();
	}	
}

I think you ought to re-read the error message. Those are not the files its talking about.

1 Like

Indeed: PawnBase.

I checked it over, changed those ones accordingly. The compile worked, but now I am not getting any shaking.

Have you double checked that the blueprint is set?

1 Like

Hello,

That did the trick. I was looking in the wrong file (again) for this last bit- I was looking in the audio files themselves to set the sounds rather than in the Pawns and projectile. It is all working well.

Thanks

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms