CreateDefaultSubobject with UBoxComponent causes crash on startup

Hello all,

I have a class called AWeapon, an actor derived from AItem, in which I declare a UBoxComponent in my .h file and use CreateDefaultSubobject in my constructor in the .cpp file. I forward declare the box component in the header and include the BoxComponent.h header in the .cpp file. When I use CTRL+F5 to launch upon compilation, I get a crash. When I remove the CreateDefaultSubobject call in the constructor, it builds and launches fine. My code:

![alt text][1]
![alt text][2]

Thanks!

Hi all,

Feeling really dumb but I realized that I used the arrow → operator rather than the assignment operator. Now, can someone tell me how to delete a post? haha.

Thanks.

1 Like

I am glad you didn’t figure out how to delete your post… because it helped me figure out the same identical mistake I made in my code! LOL

2 Likes