Compiling failed at end of lesson 198

I’m 99% sure I followed the instructions correctly but here’s the error log

Building SimpleShooterEditor…
Using Visual Studio 2019 14.29.30136 toolchain (C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133) and Windows 10.0.19041.0 SDK (C:\Program Files (x86)\Windows Kits\10).
Building 5 actions with 8 processes…
[1/5] ShooterCharacter.cpp
C:\Users\Will\Documents\Unreal Projects\SimpleShooter\Source\SimpleShooter\ShooterCharacter.h(47) : error C2062: type ‘float’ unexpected
C:\Users\Will\Documents\Unreal Projects\SimpleShooter\Source\SimpleShooter\ShooterCharacter.cpp(20) : error C2065: ‘Health’: undeclared identifier
C:\Users\Will\Documents\Unreal Projects\SimpleShooter\Source\SimpleShooter\ShooterCharacter.cpp(51) : error C2761: ‘float AShooterCharacter::TakeDamage(float,const FDamageEvent &,AController *,AActor *)’: redeclaration of member is not allowed
C:\Users\Will\Documents\Unreal Projects\SimpleShooter\Source\SimpleShooter\ShooterCharacter.cpp(52) : error C2447: ‘{’: missing function header (old-style formal list?)
[2/5] ShooterCharacter.gen.cpp
C:\Users\Will\Documents\Unreal Projects\SimpleShooter\Source\SimpleShooter/ShooterCharacter.h(47) : error C2062: type ‘float’ unexpected

this float has red squiggles in shootercharacter.h

UPROPERTY(VisibleAnywhere)
float Health;

which means red squiggles under “Health” in shootercharacter.cpp

Super::BeginPlay();

Health = MaxHealth;

also attached an image for the other 2 errors

and last thing, at 8:02, the instructor uses a keyboard command to “build” without reminding us what keys he’s pressing. I picked back up after a week of vacation and didn’t remember the keys, so i did a couple of ctrl+shift+? before finding it. the build didn’t work anyway but in future courses, saying the shortcuts every time should be a thing. or at least adding them visually overlayed in the video.

idk how to copypaste bigger chunks of code neatly but can provide more screenshots if needed. thank you so much for your help

Could you post the full header?

You can surround the code with 3 backticks

```
code goes here
```

Or highlight the text and press the </> button.

That would be Ctrl + Shift + B > ProjectNameEditor Development Build

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "ShooterCharacter.generated.h"

class AGun;

UCLASS()
class SIMPLESHOOTER_API AShooterCharacter : public ACharacter
{
	GENERATED_BODY()

public:
	// Sets default values for this character's properties
	AShooterCharacter();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
	
	virtual float TakeDamage(float DamageAmount, struct FDamageEvent const &DamageEvent, class AController *EventInstigator, AActor *DamageCauser) override;


private:
	void MoveForward(float AxisValue);
	void MoveRight(float AxisValue);
	void LookUpRate(float AxisValue);
	void LookRightRate(float AxisValue);
	void Shoot();

	UPROPERTY(EditAnywhere)
	float RotationRate = 10;
	UPROPERTY(EditDefaultsOnly)
	float MaxHealth = 100,

	UPROPERTY(VisibleAnywhere)
	float Health;

	UPROPERTY(EditDefaultsOnly)
	TSubclassOf<AGun> GunClass;

	UPROPERTY()
	AGun* Gun;
};

This should end in a semicolon not a comma.

ok I fixed that but now I can’t open the unreal project again
error2
neither option works.
did making that change without unreal open have negative consequences?
I tried reverting to the comma and opening the project again but got hit with the same failure.

Then you might have more compilation errors. What’s the output after fixing that mistake?

I think I fixed it. I had a semicolon on the end of line 51 of ShooterCharacter.cpp.

float AShooterCharacter::TakeDamage(float DamageAmount, struct FDamageEvent const &DamageEvent, class AController *EventInstigator, AActor *DamageCauser);

I deleted it and everything seems to be in order now.

Thank you so much for being active here, I really appreciate your help

1 Like

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

Privacy & Terms