Example function that tries to get the Actor underneath the player crosshair if there is anyĪActor* FocusedActor = GetFocusedInteractionActor() ![]() We didn’t duplicate anything or create anything new, we just looked up where to find the object we need, and can now use it to do stuff for us such as calling functions on it or accessing its variables. For example, AM圜haracter* MyPlayer // Get pointer to player controller, points to somewhere in memory containing all data about the object.ĪPlayerController* PC = GetWorld()->GetPlayerController() Īfter running this code, the ‘PC’ variable is now pointing to the same place in memory as the player controller we retrieved from World. In order to access your player, you’ll keep a pointer to the player class. The first way you’ll be using pointers is to access and track instances of your objects. Most commonly used to access objects like Actors in your level and references to assets in your content folders such as sound effects or particle systems. Asterisk ‘*’ (Pointers)Ĭommonly known as “pointers”, they may sound scarier than they actually are within Unreal Engine, as most memory management is being taken care of while we’re dealing with gameplay programming. I’ll explain how they are most commonly used within Unreal Engine gameplay programming, not C++ programming in general. I will explain their meaning and use cases without going too deep into their technical details. While looking at C++ tutorials, you may be wondering about a few common symbols. You can freely browse this repository to see more examples of how C++ is used with Unreal Engine. ![]() You can find the reference game example project over on GitHub. Throughout the article, I’ll be using code snippets as concrete examples.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |