Training Livestream - C++ Q&A - June 27 - Live from Epic HQ

WHAT
and are joining the livestream again to follow up the Getting Started with C++ live stream with more Q&A and live discussion about using Unreal Engine’s source code. Please reply to the post with your questions as well and we’ll get to as much as we can. Also, be sure to also check out our documentation and wiki articles on C++!

WHEN
Tuesday, June 27 @ 2:00PM ET Countdown]

WHERE
Twitch
Facebook
Youtube

WHO

  • Sr Learning Resource Engineer
  • Tools Programmer - )
  • Community Manager -

Feel free to ask any questions on the topic in the thread below, and remember, while we try to give attention to all inquiries, it’s not always possible to answer’s questions as they come up. This is especially true for off-topic requests, as it’s rather likely that we don’t have the appropriate person around to answer. Thanks for understanding!

ARCHIVE:

Awesome, looking forward to this. My only question is whether there are any plans for simplifying editor customization in the future, like adding custom objects to the Placement mode panel?

Looking forward to this

2 Qs:

http://puu.sh/w9wcN/79d171eac4.jpg

This message appears both for components which don’t have an associated UPROPERTY, but also in simulate mode for dynamically created components in a UPROPERTY array. My question is, what is the reason for this limitation? I dug into the code a while back, found the line that enforced it, and managed to trick the editor into allowing editing by creating an unrelated dummy property with a name that matched. Everything worked fine, which makes me wonder if this restriction is perhaps old and could just be lifted.

  1. I’ve seen the following in a few places in engine code:


UPROPERTY()
TMap< AActor*, Something > SomeMapProperty;


and this too:



TMap< TWeakObjectPtr< USomeObject >, Something > SomeMap;


I’ve wondered for a long time if this is safe, and if so how. In both cases, the object acting as the key can be destroyed. When the GC then comes along, assuming map properties with object keys behave in the same way to regular object properties, the key will be set to null. So you can end up with a map with multiple equal keys, which I’d think was undefined behaviour. Same for the weak ptr version. Am I missing something here, or is this only safe if it’s known for sure that nothing will be destroyed?

How do you know which header file from the engine to #include in your own C++ class? I am used to using C# and Quick Actions in VS to add the appropriate “using xxx” line. Is there anything comparable for C++?

[Question] AI Jumping C++

My biggest #Question is what function do I need to call to get my AI pawn to jump from location to location without a NavLink (proc gen makes those a non-option for me). If I call Jump() from its movement component, he jumps in place without navigating. I followed [this](post by but I don’t know how to make the pawn jump along that path! I will ask during the live stream too in case you guys don’t see this! Thanks!

I may be misunderstanding the dilemma, but when I saw this it was because I needed to give UPROPERTY() a visibility specifier like this:




UPROPERTY(EditDefaultsOnly, Category = "UPROPERTY Example)
TMap< AActor*, Something > SomeMapProperty;



All the UPROPERTY() specifiers can be found here

At the time I was working with TMaps in my project (4.13.2) UE4 did NOT like when I exposed those containers to blueprints. Should be okay with 4.15+ now though since you can make them in BP!

Will there be plans for a tutorial series for Networking in C++? I understand there is one in Blueprints but understanding the proper workflow for a simple multiplayer setup in C++ would definitely be helpful.

Book for C++ In Unreal and otherstuff

I wont make it to the stream, but I will ask my question now: What book would you recommend people read to learn C++ in Unreal Engine? And if you can answer in C#, cause after C++ I plan to learn C#. Thanks for the help! I’m not really new, I want to learn Unreal very badly. I just can barely run it, my PC isn’t the best so I can’t load high poly stuff. If I do try it’ll either crash or take 4 years, I usually will wait till it crashes. Because of this I’ve been using Construct 2, Cryengine, Unity, UDK and learning HTML. Sorry for the long paragraph but I am one to ramble on with my sentences… not really helping with my English grade either.

**[Question]
**
Does ue4 staff have a proper way of destroying an actor without causing other actors to crash when accessing data from a destroyed actor.
Should I use is valid each time I access actor x data? Or once at the beginning of a bp/c++ function?
I guess what Im trying to say is if I have one ai actor accessing data and do an is valid check but that actor gets destroyed while checking the variables of the actor like health, location etc but it already passed the is valid check will it return null or crash? This is for one of those instances that the small an actor is destroyed but another actor was checking the variables and already passed the is valid node.

[Question]
How do I make a plugin, or rather, what template would I start out with, that would add a Menu item to the Application menu bar? (ie: File -> My Plugin Here). None of the Templates seem to fit with this idea?

Sadly I’ll have to be at work during the stream but hopefully this gets answered. It would help save tons of time for me (I’m OCD about organization), and I’d submit it to be released on the marketplace for free.

[Question] Is there a way of figuring out which modules a plugin really depends on?

[Question]
So is this the method epic wants us to safetly remove actors using the destroy actor node?
Im wondering if the garbage collector will store the variable long enough for the other ai to finish accessing the variables.

So long as you’re not using multithreading in an inherently unsafe way, you shouldn’t have to worry about something being destroyed since your last validity check, so long as you’re not relying on checks made in previous ticks.

Anywhere you need to store a reference to an actor over multiple frames, I’d strongly recommend using a TWeakObjectPtr< AActor > in place of AActor* for your member variable/property. You can then do


if(MyActorPtr.IsValid()) { MyActorPtr->DoSomething(); }

The weak pointer will be updated by the garbage collector, that’s the only validity check you need to make. Do it at the entry point where you first need to access the actor; once you know it’s valid, you can be sure it will remain valid for the remainder of that scope, unless you cause it to be destroyed yourself.

Thank you that helps!!

i would like to see this topic:

How component on a gameObject (pawn/actor) are accessed in code for example if we hit an actor with our pawn so that pawn will access pawn components and will increase something. different components how to use and when to use them. basically from code perspective components types best practices examples.

What is the correct way to create objects during construction rebuild in the editor to avoid having to close and reopen the character blueprint editor?

For instance, I have added a user interface to the character editor that allows me to add weapons to the character generated at runtime. When working in the editor to get the construction script to accurately reflect the weapons added I have to close the character editor and relaunch it. After the relaunch the weapons appear correctly located in the desired placements on the character mesh.

I am using OnConstruction to currently dynamically generate and place the weapons and it works fine in editor and in game, but when setting the weapons up in blueprint editor they do not appear or appear in the wrong placement until I relaunch the blueprint editor.

Is there plans to add creation of c++ ustructs through the editor similar to c++ uclasses?

how can i make my very own game cause i have an engine what do i do