Thinking Out Loud

Make an Actor that can open the door when it enters the zone
We’ll probably use an || logic tree to allow it to open, which means we’ll need either an array of what can open the doors, or we’ll need another property for OpenDoor.

If we have a component added for that actor, that means each actor that can be picked up, will have an instance of that component, which in a larger game may have larger overhead, but that shouldn’t be an issue with our situation. I don’t know what the limits are, and I’ve never tested it.

The advantage of using a component would be that we have much better fine tuning the behavior of items in our world, so we can give that actor specific stats like IsHeavy, and IsNotATree.

That means it would be easier to add things like an outline around an object that has a certain property in order to pick it up.

Of course if it is only on the side of the object that we’re adding, then it’s a bit backwards, because it will be the component that will be doing all the work, and the player will simply be along for the ride. This would quickly become a cable management headache and would bloat the code larger than it would be necessary to make things work.

I think in a larger game I would go for a component approach as well, but I’d try to go for something structured similarly to react, where most components just stare at the event god waiting for something to happen, and when it sees that it is their time, they do the thing they’ve been made for. Of course that might be a bad idea, I don’t know.

Normally I would go with a HasGrabbability, and HasAbilityToPickUp relationship, and then an EventHandler class that would actually handle the events sent to it to relay the messages that things are happening. That brings up the question of how we grant the default pawn the HasAbilityToPickUp component.

So for this we’ll need to modify UOpenDoor, and create a HasGrabbability componenent to the object. It’ll pretty much be scanning for the actor to pick it up each frame, and then once it’s been told that it’s actually picked up, it will modify it’s position relative to the actor that picked it up until it is told not to modify it’s position anymore.

We’ll probably need to use something like FMath::FInterpTo() to transition the object to be within a certain threshold as the player.

Then we’ll figure out which way the player is facing in order to do more math to keep the object in the players viewport and relative to the players movements.

Of course, I’m normally wrong about the majority of the way I actually execute my code, but I find these fun thoughts.

4 Likes

This actually really good and you should keep it up. But I would keep it on one forum post so you can see your thought process as you progress your learning journey.

2 Likes

Privacy & Terms