Thanks, I’ll fix it for forward declaration to fix the error. Just not sure why it work in the survival project code. It compiles just fine. even though I can’t see any class ASWeapons prior to the TArray. Anyway, thanks.
OK, maybe I’m missing something as the jump looks the same to me as how the character jumps in ShooterGame? Do you add more functionality to jumping in a later section (I’m only up to section 2 so far)? Could you point out where I can find this additional functionality so I can study the difference between what you are doing and what the default jump does in the Character Movement Component?
How would this work with the ray tracing when testing if the player is looking at a usable object? Would you get the actor the player is looking at and then check if it has the usable component attached to it before proceeding? Sorry I’m new to UE4 so am trying to get my head around these concepts.
I’m not sure what you mean. The jump does indeed do pretty much the same thing as ShooterGame, which in turn uses character movement component. So there there is not much to compare.
It could check for an Interface on the traced Actor, which defines what functionality a class is expected to have. In this Interface it would be the Component, so we could check if the Actor has the Interface, and then call Use() on the component.
I noticed there isn’t a lot of information on C++ interfaces, the docs talk about Blueprint interfaces, the concept is the same though so it might be worth a read:
https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/index.html
https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Types/Interface/UsingInterfaces/index.html
I have a question about this section. I just came in here, hoping to learn C++ coding for UE4, but I have a problem with the files.
If I’m not mistaken, the CPP and H files you linked to at the start of the first section, already includes the code you have added for the other sections as well. If this is the case, then this tutorial will essentially only be accessible to people who were doing it from the very beginning. I mean, as of writing, just the character class is already about 1000 lines long. To me this is extremely confusing and already kind of overwhelming, as I am not certain what code I need to write to make this first section compile without any mistakes (for instance, I already have to take in account at least the base character class, considering it is what the character class is extended from, and I have no idea what functionality written in the character class is reliant on what included class).
Is there any plan or way to make it so people that found these tutorials later (like me) can also follow along?
You can jump back to previous sections using the individual Branches on GitHub, for example section 1:
https://github.com//EpicSurvivalGameSeries/tree/Section-1
I hope that helps you a bit in getting into the code, especially Character has grown a lot more than I had anticipated
Where do you assign your DefaultPawnClass?
I couldn’t see that anywhere in the code. And I know when I start I project from scratch, I can’t get my character to spawn without defined. Am I missing another way?
Specifying the default pawn is handled in the Game Mode. In this project, specifying the player pawn class isn’t actually done in code. If you look in the Editor, there are two game modes [FONT=Courier New]DebugGameMode and [FONT=Courier New]SurvivalGameModeSetup, which both descend from [FONT=Courier New]SGameMode. The default pawn class from [FONT=Courier New]AGameMode is overridden in these two blueprints, which you can find in the Classes section of the Class Defaults tab.
It’s pretty common to create one or more blueprint subclasses of your C++ class. That gives you the flexibility to use either Blueprint or C++ (and easily move logic between them) and gives you the ability to use the built-in features of the editor when it makes sense. If he had wanted to set the pawn in [FONT=Courier New]SGameMode, it could have been done the constructor and looked something like this:
DefaultPawnClass = SCharacter::StaticClass();
if the character class you wanted to use was a C++ class, it’d be something like this:
static ConstructorHelpers::FClassFinder<APawn> PlayerPawnOB(TEXT("/Game/Blueprints/Characters/Character_BP"));
DefaultPawnClass = PlayerPawnOB.Class;
(note - code typed in editor, caveat emptor, may not compile )
In this case, it looks like put his common logic into the C++ class and then the things he wants to change between debug and non-debug into the blueprint class (which is a good idea I’m going to steal).
Hi ! Thanks for answering that is such detail
Our top-level character class is a Blueprint “PlayerPawn” (Meaning assigning SCharacter::StaticClass() in code won’t give you properly set up character) I’d like to avoid content references in code whenever possible (I might still add this specific case to the code just to demonstrate that it IS possible to do)
Thank you for the explanation.
What confused me is, section 1 of this project has the game mode set to the SurvialGameGameMode, which is the C++ class, not the blueprint class. And has the pawn was set to DefaultPawn, not PlayerPawn BP. For me, based on what you said, I created a blueprint class based on my empty game mode c++ class, and within the BP, I assigned all my items. I do like this method much better. Thanks
The map must have been set to override it to the BP variant through the map’s World settings. Otherwise the game would have not worked.
Nice tutorial. Thank you
when i compile the code of section 1,there is a compile error about the func below
void ASCharacter::OnLanded(const FHitResult& Hit) override;
it seems that OnLanded isn’t a virtual member function.
my engine version 4.8.2
i just don’t understand.
The API changed from 4.7 to 4.8, section 1 code branch and docs may still include some references to 4.7 (and should be updated to 4.8 once the project is up on Learn-tab) the complete download of the project has all updated code of 4.8. OnLanded is one of those functions that was altered in 4.8.
thank you.
I had a thought, based on outline material, how does one fix it so different types of objects have different color outlines?
I assume we create a MID maybe for types of objects. A bomb type for example could have a red color, Food would be yellow. Then in the ray cast, we create the MID and assign the color from the object? I’ve not worked much with MID, so am I even on the right path?
Just not sure how to access the blendable material in the PP volume through code
That doesn’t work for multi-color objects in a single post-process pass. the effect uses a single channel depth value from CustomDepth. By default can’t encode any kind of objecttype data into this buffer and therefor can’t apply different colors to different objects.
One user made a mod to the engine that allows custom tags to be used https://github.com/Temaran/UnrealEngine/tree/4.6CustomTagBuffer that effectively enables the use of multi-colored outlines.
I’ve been trying to learn from this and testing in multiplayer.
After I built the SUsableActor > SPickupActor > SConsumableActor and Use() functionality in my own project I noticed the “PickupSound” was playing pefectly on my Server viewport, but no “Pickup Sound” would play on my Client viewport – all the other sounds replicate to the client window (ie SBombActor), so Im confused…
I’ve created an Attenuation and have assigned it to the PickupSound cue. But that didnt solve the problem for me.
After playing with it a bunch, I think it only plays in the server window due to the following line, but this is how the tutorial does it… so Im confused:
void ASCharacter::Use()
{
// Only allow on server. If called on client push this request to the server
if (Role == ROLE_Authority)
{
ASUsableActor* Usable = GetUsableInView();
if (Usable)
{
Usable->OnUsed(this);
}
}
else
{
ServerUse();
}
}
I can swap some lines around and design the function similarly to SetIsJumping() or SetSprinting()
void ASCharacter::Use()
{
ASUsableActor* Usable = GetUsableInView();
if (Usable)
{
Usable->OnUsed(this);
}
if (Role < ROLE_Authority)
{
ServerUse();
}
}
and that can play the sound fine on the Client, but Im guessing its not the right way to do it.
Anyone else know what might be going on? The tutorial game version functions correctly, but mine doesn’t, and Im not sure what Im doing differently.
Hi turtle,
One way to handle this is to locally (client side) check if the pickup will succeed (in this case we can perform a trace on the client and see if we find a usable item) if that returns an object we can play the sound immediately. THEN send the request to the server to do the actual pickup logic.
The other way or dealing with this is to have the server send a respond back to the client if we indeed successfully picked up the item, but keep in mind that it will cause a delay because of the round-trip and in turn, makes the game feel less responsive.
The first example is “safe” because we only played a sound locally, and did not execute any real pickup/use logic on the client. If you have different types of pickup/use audio per item, you can use the same logic, and fetch the audio file from the returned Actor when calling GetUsableInView() on the client and play that file on the client before sending the request to the server.
Now for the implementation…
What I like to do it to split the real logic from the local client code when the key is pressed (as you can see we did with sprinting etc.) so you could add a function OnUse() which is bound to the “E” key and handles the above example of tracing locally before sending the request with Use(). This way we don’t have to check inside Use() if we should play the sound by checking if we are the owning client or remote server, etc.
Hope that clears things up!
&stc=1
i can’t find the “bomb gray edge” realization,how to do this?
Im on work and I get the url bloqued by a proxy, but i think he is using this:
http://www…com/ue4-evolves-outline-post-effect/