#CombatComponent suddently not existing

43 messages ยท Page 1 of 1 (latest)

grand oar
#

I am at lesson 74. And suddently the character decided not to want to pick up weapons anymore. I made various logs, and found out the CombatComponent isnt valid, when i try to equip weapon.

You can see how i make and set it at the image (i don't believe i changed anything here).

At the EquipButtonPressed "Hello" is shown, but bot "Hello2"

At the CombatComponent constructor "Comb" is also shown which tells me it should be existing properly.

The "PickUp" widget shows over the waepon, so it registers the overlap properly.

I use 5.1, and test 1 player mode, so it is not a network issue.

I have tried to delete binaries and rebuildseveral times, as well as reopening the editor.

Can anyone help? Cheers ๐Ÿ™‚

dull sinew
#

it looks like you're in between lectures, the whole call to authority and equip weapon should be called in serverequip, not equip ๐Ÿ™‚ if Stephen hasn't done that in the lecture it's likely in the next one ๐Ÿ™‚

grand oar
#

It was between 73 and 74 i encountered this

#

The current github branch looks like this, so that should not be an issue, as it worked before ๐Ÿ™‚

dull sinew
#

yeah I just had a flick through all the commits from that section and he doesn't seem to fix it, he must do it later! Here's the code, hopefully it fixes it ๐Ÿ™‚

#
void ACosmicBlasterCharacter::EquipButtonPressed()
{
        if (Combat)
    {
        if (Combat->CombatState == ECombatState::ECS_Unoccupied)
        {
            ServerEquipButtonPressed();
        }
    }
}
void ACosmicBlasterCharacter::ServerEquipButtonPressed_Implementation() //for client use
{
    if (Combat)
    {
        if (OverlappingWeapon)
        {
            //GEngine->AddOnScreenDebugMessage(-1, 8.F, FColor::FromHex("#FFD801"), __FUNCTION__);
            Combat->EquipWeapon(OverlappingWeapon);
        }
    }
} 
#

you might not have the combat state yet so ignore that ๐Ÿ™‚

grand oar
#

What i had worked perfectly before with this code, so i am not looking to "jump ahead". I would like to know why this specific line of code will not run. So the CombatComponent is null for some reason, and i cant figure out why ๐Ÿ™‚

dull sinew
#

in your character BP, can you fully see everything in the details panel?

grand oar
dull sinew
#

in the combat component that is ๐Ÿ™‚

#

aha

#

oky

#

so

grand oar
#

Details is empty when its sleected

dull sinew
#

yeah that's what I was expecting, this happened to me too

#

you need to fully rename the component in cpp

#

then it'll work ๐Ÿ™‚

grand oar
#

So both cpp and .h file and all references?

dull sinew
#

yeah so where you're creating it in cpp, from there

grand oar
#

So i need to create a completely new component in UE, or can i just rename it inside visual studio?

dull sinew
#

just rename it

#
    Combat = CreateDefaultSubobject<UCombatComponent>(TEXT("CombatComponent"));
    Combat->SetIsReplicated(true);
#

you can right click on "Combat" and click rename, it'll find everywhere you're using it and rename them all for you

#

I'd change the name inside the TEXT("") too just to be sure

grand oar
#

And then rebuild it all?

dull sinew
#

I changed mine back to Combat once it was back up and running, so it was easier to check my code with Stephens

#

if you close the editor and hit CTRL + F5 in visual studios, it'll recompile and launch the editor for you, all changes will be there

grand oar
#

Do you happen to know it occurs?
Something like this scares me a lot, that suddently something is just broken without throwing a warning. In a large project, this would only be found in a playtest of this exact feature.

dull sinew
#

I wish I did, a few people have said it happened to them, might be worth searching in the channel, someone with the expertise may have said why ๐Ÿ™‚

grand oar
#

It works now, so it helped renaming it. Thanks a lot ๐Ÿ˜„
But it really removes the sense of security when something like this can just hapen out of the blue.

dull sinew
#

that's okay, glad I could help ๐Ÿ™‚
yeah it is worrying, I can only imagine it's an UE bug, but I'm hoping it doesn't affect packaged builds!

grand oar
#

Maybe @warm sphinx can explain this, or help on how to prevent it? ๐Ÿ™‚

dull sinew
#

you probably don't want to ping Stephen with something like this (it's against the rules), but some hard Google searching will likely find something ๐Ÿ™‚

#

or a post in the UE forums on their website ๐Ÿ™‚

warm sphinx
grand oar
#

Sorry about that ๐Ÿ™‚
Hoped that it was "common knowledge" of some sort.

I have a game called King of Retail on Steam, fully made in BP with tons of Blueprints referencing each other. I can only imagine a reference breaking without any warning, leading to many obscure bugs hidden somewhere, leading to a much more extensive bug hunt period before each update.

dull sinew
#

I'm guessing it's a cpp to bp issue as we're manually creating it rather than using the bp that's available, so hopefully your bp game is safe ๐Ÿ™‚ I have a bp game of my own and so far no issues!

lunar flax
# grand oar Do you happen to know it occurs? Something like this scares me a lot, that sudd...

Not @dull sinew but yes I do know why. Welcome to Live Coding breaking things. So basically what happens is if you create a component and compile with the editor open the ctor doesn't run because it already ran when you first opened the editor. Since the ctor doesn't run a second time, the create default object and libraries (both static and dll) don't get updated and no changes are reflected inside the editor. BP knows the component exists because C++ tells it that it does, but beyond that BP has no idea. By changing it's name and rebuilding the changes get pushed to the CDO and libraries thus causing the changes to reflect. Lol clear as mud?

wooden zealot
#

I'm glad I just always close the editor down now when compiling, don't wanna think about that lol

tropic umbra
#

Maybe I'm a really lucky one here, but actually I use the Live Coding almost always (running with 5.1.1), and never ran into issues, so actually began to love that cool thing. Yes, of course, sometimes strange things happen, but in this case, I stopped to start search for bugs in my code and instead really do a Ctrl-F5 compile before going into debugging. But this happens in 1 of 10 cases or even less and, most important nothing gets damaged.
I hate restarting the editor each time for some simple changes in code - but as Dohlar said: that's scaring. The former "Hot Reload" was a real mess, and I did run into trouble with this, getting components lost - so the rule was not to change any header files with editor open for me. Shadow001's explanation makes sense, hmmm, getting confused and scared again...

lunar flax
#

Lol well I hate to be "That guy" but Hot Reload still exists in UE5.X.X I don't understand why you folks hate closing to compile or like a sensible person running your editor through Visual Studio / Rider. IMO and only imo the UE crash log is total trash and makes debugging that much harder. If you don't run through the IDE in debug mode, you can't use break points (which are amazing), you don't get an actual useful crash report etc... LOL ok /rant over