The first thing that came to mind for me is the “IsOverlappingActor” function we used for the pressure plate to do a “pull-based” collision detection. I remember we talked about there being “collision events”, and I would rather use these as a subscription will be much more efficient than checking for a non-existent collision every frame.
I would create a C++ component for handling the collisions with relevant objects I want to make “pickup-able”. I would add this component to these static mesh actors. I’d want a weight property on this component so we can set it for each static mesh actor. When we collide, then we would want to translate the object so the pawn will “carry” it with it. I’d like to use a specific key or click to initiate this action as we will also want to be able to put the object down. This C++ component will also need the OpenDoor component that we can inject as an editor property so we can interact with the trigger volume and add/remove a weight. We’d want an instance of the FirstPlayerActor as well to be able to change the speed while carrying an object.
I’d want to add methods on OpenDoor:
- Add and remove a weight
- Check for trigger volume collision
OpenDoor could have an abstraction for keeping track of the weight objects as a separate class or just keep them in a std::vector or FArray. It can then iterate and sum the weights - use std::accumulate and if above a threshold that could be an editor property then it would trigger “OpenDoor” and if below the threshold then trigger “CloseDoor”. The pawn itself could have a weight so that we could keep things more generic.