Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to call and use AbilityTask_SpawnActor in C++ #36

Closed
ughstudios opened this issue Aug 17, 2020 · 2 comments
Closed

How to call and use AbilityTask_SpawnActor in C++ #36

ughstudios opened this issue Aug 17, 2020 · 2 comments

Comments

@ughstudios
Copy link

How do we call BeginSpawningActor(), and FinishSpawningActor()? They require an AActor* for FinishSpawningActor, and BeginSpawningActor requires an AActor*&? Also, UAbilityTask_SpawnActor::SpawnActor() also requires a reference to the class, but not location, but beginspawning requires location. This whole function is bizarre to call in C++. Any tips?

@Bit-Rot
Copy link

Bit-Rot commented Aug 17, 2020

Note that this issues section is for issues specific to the GASDocumentation repo, not for general unreal dev issues or general c++ issues.

What you're looking at is a common c++ technique. Do a search for "c++ pass by value vs by reference" and "c++ pointers" for resources on this issue.

TL;DR: You're passing a AActor pointer by reference to BeginSpawningActor(). Begin SpawningActor() sets the value of that pointer to the AActor it just spawned. You can then do whatever you want with it before calling FinishSpawningActor(). Or, if you don't need to do anything special with it between spawn time and blueprint construction script, you can just call SpawnActor() in one go.

@ughstudios
Copy link
Author

Makes sense. Actually, I had to call BeginSpawningActor() and FinishSpawningActor() for it to work.

@tranek tranek closed this as completed Aug 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants