Fstring HiddenWord isn't working nor is Intializegame():

Not sure why but my FString HiddenWord; in my header isn’t showing Green & blue like it for yours I have the exact same code. Also void UBullCowCartidge::InitializeGame(); doesn’t work for me for some reason.

This is my header
// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include “CoreMinimal.h”

#include “Console/Cartridge.h”

#include “BullCowCartridge.generated.h”

UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))

class BULLCOWGAME_API UBullCowCartridge : public UCartridge

{

GENERATED_BODY()

public:

virtual void BeginPlay() override;

virtual void OnInput(const FString& Input) override;

void InitializeGame();

// Your declarations go below!

private:

FString HiddenWord;

};

This is my CPP
// Fill out your copyright notice in the Description page of Project Settings.

#include “BullCowCartridge.h”

void UBullCowCartridge::BeginPlay() // When the game starts

{

Super::BeginPlay();

//Welcoming Player

PrintLine(TEXT("Welcome to the Bull Cow Game!"));

PrintLine(TEXT("Guess the 4 letter word!")); //Magic Number Remove

PrintLine(TEXT("Press Enter to continue"));

InitializeGame(); //Setting Up Game

HiddenWord = TEXT("cake");



//Set Lives

//Tell Player How Many Lives

//Prompt Player For Guess

}

void UBullCowCartridge::OnInput(const FString& Input) // When the player hits enter

{

ClearScreen();

//Checking PlayerGuess;

if (Input == HiddenWord)

{

    PrintLine(TEXT("You Won!"));

}

else

{

    PrintLine(TEXT("You have Lost!"));

 

    //Check If Isogram

    //Prompt To Guess Again

    //Right Number Characters

    //If wrong guess Remove Life

    //Show lives left

    //Guess Again

    //if 0 you lose

    //Prompt to play again press Enter to Play Again

   

    /* Unreal Standards

    PrintLine(TEXT("Your String here"));

    */

}

}

void UBullCowCartidge::InitializeGame()

{

HiddenWord = TEXT("cake"); // Set The HiddenWord

//Set Lives

}

Doesn’t work, how? Also pay no attention to the colouring the editor gives you for variables.

It tells me this

Oh you misspelled the class UBullCowCartidge vs UBullCowCart r idge

thank you for helping it solved

1 Like

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

Privacy & Terms