BP Event Implementation problems + C++

Sooooo…

I am trying to handle the OpenMotion event in my BP.
image

This is then supposed to be called this if the Item I am interacting with is a door that can be opened.
image

PROBLEM:
The event is called but doesn’t play.
Yes, the event gets called properly.

I can’t find any helpful resources around, so can anyone help me out a bit?

you havent told us what the problem is, is the event not being called?

You’re trying to cast AItem to ADoorItem is it right?

... = Cast<ADoorItem>(this); // this = AItem.

The same for AUtilityItem.

You could use:

UE_LOG(LogTemp, Warning, TEXT("Before cast"));
if (DoorItem)
{
   UE_LOG(LogTemp, Warning, TEXT("Cast worked"));
   ...
}

To make sure it worked.

This seems to be better with Interfaces:
https://docs.unrealengine.com/5.3/en-US/interfaces-in-unreal-engine/

Pardon me, you’re right!

The event gets called, alas, it doesn’t play the animation.

I’ve never used blueprints, but my team member requested me to implement it right this.
It worked when the animation and rotation was handled by the code.

Connect Door Timeline’s Update to Set Actor Relative Location.

I tried and the LOG works. The function gets called, but the animation does not play.

Tried rn, not working.
I tried adding a LOG to the blueprint and it looks like the blueprint gets called properly.

Perhaps I should adjust the timeline?

Probably! But don’t forget to connect the Update to Set Actor Relative Rotation ( as you connected Open Door Motion to Play from Start, otherwise Set Actor Relative Rotation will never be called.

Door_Stashable_game.zip (111.9 KB)

There are two separate interfaces

  • Openable
    → Open
    → Close
    → isLocked

  • Stashable
    → Interact

Of course you could let them all have a common interface and just call Interact on them, but that was not your question so I’ll leave you to read up on the pros of interfaces.

Clicking on an openable will toggle it, stashable will collect it (destroy & show message)

Remember to right click uproject and generate the solution before running

1 Like

Thank you for your time!

I found out the problem was something very stupid, as in: it was rotating only the collision box of the door, not the door itself.

But I will follow your suggestion to update the whole system. Thank you!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.