The Witcher Medaillon Mechanic

I am a huge fan of the witcher saga, I love books and the games.

As a tribute to my favorite saga, I decide to redo a mechanic using unreal engine 5.4, C++ and Blueprints.

But first, what is exactly the witcher medaillon?

The Medaillon is magical item that you were given by master in your clan. It help you with detecting an enemy or magic around yourself (depend on setting)

Prerequisites:

  • Unreal Engine 5.4
  • Visual Studio 2022
  • C++ plugins for Unreal Engine
  • .NET 3.1 (the newest version)

Step-by-Step:

Basic Medaillon classes:

What do you need is know wich parent you should use, I choose Actor, because I work with them and it is super easy, and more operative with inheritace

What we need is basic Actor classes for:

  • Enemy
  • Medaillon
  • Player

But here is catch, player could be an Actor but will need a lot of work, we should use a player character instead.

So let’s begin!

Open your project and make sure you add new C++ class – Actor, then give him a proper name, wait until UE is build. Do this for two-times, for the third time choose a player charater, then wait until UE is fully build. Refresh project in VS, and ou are free to play with C++ 😀

If you choose properly the your code will be just like my, what do you need to know is be aware about Naming classes_API, if you are coping my code and it will not working, change a name of the class

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

pragma once

#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "Medailon.h"
#include "TheWitcher.generated.h"

UCLASS()
class WITCHER3MECHANIC_API ATheWitcher : public ACharacter
{
GENERATED_BODY()

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

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;

// Add medailon to class
UPROPERTY(EditAnywhere, Category = "Medailon")
TSubclassOf<class AMedailon> TheWitcherMedailon;

// Reference to the spawned medailon actor
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Medailon")
AMedailon* SpawnedMedailon;

void ActivateMedailon();
};

Next step is playing with this mad word, attach a medaillon to the witcher. Only One witcher can have one medaillon.

Then after you have attached, build a debug sphere, and you will see where is medaillon attached.

After you know the position, then make a functions with detecting an enemy and magic. Do not forget to call setting between The Witcher and Medaillon! in my project is called ActivateMedailon in C++ file.

Debuging and Debugging and Dubuging…

Debuging a C++ project is not funny at all 🙁 it is a lot of pain a hidden pain.

What is a most common mistakes is:

  • Misspalled variable
  • I do not know something aka forgot to import a library
  • Build was not cusscefull bc error with vsxproj

And this just a few of them that I can remember.

How to really get from this mistake to fully build?

With misspalled variable is easy, just do not write it do copy cat thing 😀

with import library is tricky a little bit, I have that issue with OverpalResult.h 😀 just use google, Chat GPT did not working 🙁 unfortunettly

And error with build project is common yea, a lot of pain. This is how to get rid of it:

  1. Any Updates? Update first!
  2. Close UE
  3. Open VS
  4. Any Updates? Update first!
  5. Right click on project (it is strong highlight)
  6. click on clean
  7. wait until it is done
  8. click on rebuild
  9. wait until it is done
  10. was build successful?
  11. Yes / then Start your UE project 😀
  12. No / Fix that issue man!!

After that pain we have a C++ fully functional code yeah!

Blueprints and C++? How?

it is very easy, just add new Blueprint Class and choose a parent. Then hit play in editor, you will be able to detect enemy threats.

Congrats you survive 😀

Download code


Posted

in

by