The implementation I’m planning on will have the following properties
- Grabbable objects will be an AActor with a component called GrabObject.
- When a player presses the interact key (to be determined, possibly the E keypress), the player actor will check the area they are facing up to a certain range and query the closest actor if they have a GrabObject component. If true, then it will be grabbed, and ignored if they are not. If the player is already grabbing an object when they press the interact button, then it will be dropped.
- The GrabObject component will store a boolean which will determine if it is being grabbed. While true, GrabObject will get the Player’s current transformation and set the pivot of the grabbed Actor to the player’s location. This way, the object’s coordinates and rotation can be offset relative to the player’s current transformation while being grabbed. Once “ungrabbed” the pivot will be restored to the center of the actor’s mesh.
- The GrabObject component will also store a variable called Weight which will be used as a threshold for opening the door.
- A reimplementation of the DoorOpener component will be done. It will check if an actor with a grab object component is overlapping with trigger volume of the pressure plate and query the weight value. If the total weight value of the actors overlapping the trigger volume exceeds a threshold, then the door will open.
- If an actor is moved away from the trigger volume such as that the total weight of the pressure plate is no longer above the threshold, then the door will close.
- For optimization, the player actor will not need the above check and will automatically cause the door to open if they are overlapping with the trigger volume.
Kindly point out if I missed anything so I can improve my overview of the design.