Adding PressurePlate Actor Ref to the TriggerActors in PressurePlate class?

Hello,

First of all, thank you very much for this awsome course ! :slightly_smiling_face:

I was wondering in this lecture if somehow we could add the pressure plate actor reference to the trigger component TriggerActors array directly from the pressure plate cpp file/class ?
Since the logic to move down the plate is (at this stage of the course) specific to the plate itself.
I tried to add the ref in the PressurePlate constructor with Transporter->TriggerActors.Add(this) but when I launch the game, the list stays empty, I suppose this is because “this” ref is nullptr until the end of the PressurePlate constructor call itself ?
I then tried to call the same line in the BeginPlay() method of the PressurePlate, then a Ref is added to the list at runtime but the logic still doesn’t work. I suppose this is because the “BeginPlay” method from the Transporter is called before the one from the Pressure Plate ?

Is there any way to achieve this properly ?

Thanks !

Hi and welcome to the community.

So, let me check I am understanding you correctly. You want the pressure plate to update its reference in the transporter/moving actor so when it is triggered by stepping onto the pressure plate, the actor moves?

Hi !

Sorry, I will try to be more clear (English is not my native language)
I would like to call
Transporter->TriggerActors.Add(this)
somewhere in the PressurePlate.cpp instead of the call

if(bOwnerIsTriggerActor)
{
   TriggerActors.Add(GetOwner());
}

made in the Transporter.cpp BeginPlay method.

The idea for me is that setting the trigger actor is part of the Pressure plate logic more than the trigger logic itself.
Does that make sense ?

And also, having to check the “Owner is Trigger Actor” property in the Pressure plate blueprint feels it could be “avoided” (even if it is perfectly clear).

Ok, This makes more sense now. It should be possible to do this but I’m not sure. I have to say how you describe it is how I am trying to do this but I see weird behaviours so I am not convinced this actually works. Let me keep exploring and I’ll get back to you.

Right, my findings. I would have liked to have thought I could get it working but after digging for a couple of hours (everything seemed to be fine) I gave up, applied the changes to the course and that works fine. I can’t be 100% sure but I think it’s a creation order thing. I checked and the actor comes through the same when using this but I suspect something isn’t right.

I’d much prefer using a timeline to animate the platform as I think the Transporter component, while brilliant, is not the right thing for something like this. It does work as it is originally defined.

I considered thinking of a way to Get the Owner in Transporter and check the type and if a BP_PressurePlate then configure it. This gets rid of the boolean.

Sorry I can’t be of more help

Hey, thank you for taking the time !
I bellieve you are right and it has to do with the order the “begin play” methods are called between the different classes.
I ran into the same kind of issues with another project in blueprint.
Maybe that is why Kaan did it like this :slight_smile:
Anyway, I finished the course yesterday and I learned a ton !!
Already trying to apply some of the stuff I learned to a VR coop multiplayer mini project for the Quest 2/3 I am trying to do :grinning:

1 Like

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

Privacy & Terms