Hi all - I am very new to Unreal, not so new to C++, and in need of some help! I have a UserWidget in my game - when a button is pressed, I would like to run a function from a C++ code that locks or unlocks a door.
This is the function, .cpp:
void AMyActor::toggleLeftDoor(){
if (leftLocked){
//unlock it
leftDoorTrigger->SetActorEnableCollision(true);
leftDoor->SetActorEnableCollision(false);
leftLocked = false;
print("Left door unlocked");
}
else{
//lock it
leftDoorTrigger->SetActorEnableCollision(false);
leftDoor->SetActorEnableCollision(true);
leftLocked = true;
print("Left door locked");
}
}
And .h:
UFUNCTION(BlueprintCallable, Category="Door")
void toggleLeftDoor();
Both of which are in an actor class. This class has an actor object in the scene (placed, not spawned). I think I am running into problems with how I’m referencing this function in my widget blueprint. Here’s the gist of it, only part not shown is that Toggle Left Door and Toggle Right Door are hooked up to audio, which appears to be working just fine:
“Door Logic” here is a blueprint reference to the aforementioned actor object. While I’m not getting any error messages, Toggle Left Door and Toggle Right Door don’t appear to be running. Any thoughts or suggestions?