Is it not possible to call GetWorld()->SpawnActor<>() from an ActorComponent?

I have an ActorComponent that sort of wraps around an AActor that is a representation of a Fireball. The idea is that calling a function within the ActorComponent handles all the logic one would want for an attack(Cooldown, tracking, etc).

The issue is, when i call SpawnActor<>() to instance the fireball, it simply refuses to do so, and doesnt throw any errors. Here is a snippet of the function that handles spawning

If any additional context to answer or try resolve is needed, please say so. Thanks in advance.

It doesn’t look like you’re indicating a class to spawn, is that international ? usually a derived BP class is used where you have the visual side of things setup.

Also - you can set a breakpoint on this function and then run the editor by clicking Debug in your IDE, then play your game in PIE and then throw a fireball. The IDE will stop (break) with this function showing in the debugger. You can then step into/over the SpawnActor call to see whats happening.

Inability to spawn is almost always because of collision. You’ll need to specify some collision parameters to Spawn, or ensure that you’re not spawning inside something.

1 Like

The fireball was spawning inside the player. Simply making it spawn a bit further out fixed it. Thanks!
Saved me from a headache