Announcing Section #1 for Survival Game - Third-person Player Setup

FocusedUsableActor should be Initialized to NULL?

Hello .I have a doubt in the Tick function


ASUsableActor* Usable = GetUsableInView();

		// End Focus
		if (FocusedUsableActor != Usable)
		{
			if (FocusedUsableActor)
			{
				FocusedUsableActor->OnEndFocus();
			}

			bHasNewFocus = true;
		}

Here we are comparing FocusedUsableActor with Usable. FocusedUsableActor is Uninitialized initially, won’t it cause Undefined behavior.Should we not initialize to NULL in the constructor.

It’s not required to initialize to nullptr (We only use nullptr, NULL is only used for Windows platform specific functions) but it’s clean if you make a convention of doing so.

UObjects (which includes our SUsableActor) are automatically cleared to zero. So the above code will not cause any issues when not initialized to nullptr.

Oh ok. Thanks . :slight_smile:

hey I just started to use UE4 so Im new sorry about it mmm and try to build something new so decided to learn something about from your game but I have no idea how to add custom character also animations ?

Hi
Big thanks for such a big thread…
I am still a newbie in UNREAL stuff…
I was wondering…
Could you describe a little more mechanics of UE4 … I mean mostly whats is going on under C++ code… For example under your Scharacter.cpp at the beginning you have typed

ASCharacter::ASCharacter(const class FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer.SetDefaultSubobjectClass<USCharacterMovementComponent>(ACharacter::CharacterMovementComponentName))

I have some notion about object programming , pointers , classes… BUt this still confuses me a lot…
Could explain a little bit what for is it?

Hi Wilq!

That is a particularly odd one I agree! What I essentially do is make a change to the parent class (ACharacter) and tell it to use our own custom USCharacterMovementComponent instead of the default class that would otherwise be instantiated inside the constructor of ACharacter. It’s something you don’t commonly use (but can be quite helpful to know about when using lots of custom classes)

I hope that answers your question!

how to do this ? i still can’t find it.

Are you sure you are in the right context? eg. in a state transition (where you need to return bool to tell the state machine yes/no to switch to a new state)

Here is an example:

State A
– State Transition (Arrow that points to B)
State B

State A must has the animation you want to check time remaining on.
The node Time Remaining (with the animation included in the node name) will only be available in the state transition.

Hope that helps clarify how things work with state machines!

Hey, I’m really thankful for this tutorial, everything works so far, but I still got some questions.
1st, compared to your code, Unreal’s Default Player uses “check(InputComponent);” before binding the keys. Any thoughts about this, why are you not using it? <3
2nd, why are you using “virtual” for the function “MoveForward”. * I guess you are using subclasses that derive from SCharacter later and want to implement the MoveForward function for each of the subclasses? <3

Hi Ninjin

1st: It’s just an extra safety check whether InputComponent is null or not, nothing major - we are calling the base function using Super::SetupPlayerInputComponent(InputComponent); so the check(…) will happen already.
2st: Had a quick look, and doesn’t look like this required to be virtual afterall!

Hey, how can I see the way you connected your variables to the blueprints?

If you’re looking to see how I exposed the variables in C++ so that Blueprint can make changes, have a look in the .h header files of the project. using UPROPERTY(…) gives several options for exposing these variables (eg. UPROPERTY(BlueprintReadWrite, Category = “General”) )

No, what I ment was, how you used these variables in your blueprints, you exposed them so you must have actually used them somehow?? I guess there must be some blueprint files to be found in your project?

When exposed I only used them to tweak the variables, if at all. It’s a 99% C++ project, so I barely did any implementation of blueprint graphs in the entire project.

So you will find a bunch of Blueprints in the project, like the ClassicBomb which doesn’t have much blueprint logic (besides playing a sound on collision impact) but the Blueprint is necessary to assign content (mesh, FX, sounds)

Hope that helps,

Yes that is just what I wanted to know, thx. Finally a proper resource to learn unreal c++.

Hi ,

Thanks for the great learning resource. I just started this project and try to build it section by section referring to this project. But section branches I get from GitHub can’t be opened. “project-name”.dll needs to be rebuild and it always fail. If you have any idea how to fix it, that would be great. Thank you very much!

The section branches of Github are fairly old by now. The early ones were build against 4.7 and 4.8. I recommend using the latest Master which works with 4.12. Otherwise you’ll need to open the project using Visual Studio and fix the compile errors (since the API of UE4 has changed from 4.7 to 4.12)

Im getting infinite jumping :confused:

Hey! Great work! But there is soemthing that is getting on my nerves and dont know how to fix it…its infinite jumping, if i spam backspace it jumps inifnite how much i want , how could i put a delay? noob question haha kinda new to UE4 :slight_smile:

Heard more people about this. Must be a bug introduced after upgrading to newer editions. I will look into this and update GitHub, thanks for pointing it out!

Edit: Updated Github with the fix for infinite jumping.

Hi ,

Thanks a lot for teaching me so much! THe Only thing I want to ask is how to create “STypes.h”.(did it derive from something special?)
I am a newb…