Component vs Inheritance Question

Dunno what really to put, but couldn’t we do a collision between the chair and player. Have a command key that picks up the chair. From there have property in the player class that says grabbedObject or something and have it point to the chair object.

How would the collision and the grab command key interact?

What would you do on collision? Automatically grab? Would that be fun for the player, being a chair magnet? And then what would the grab key be for?

Putting aside the collision, what you’re saying makes sense. It could be useful to store a reference in the player to the grabbed object.

But as it turns out, the Unreal engine has builtin support for this, in the form of the PhysicsHandle: it includes a reference to the grabbed object (which it calls GrabbedComponent).

Keep in mind I was just thinking of a way to do it with the tiny slice of unreal I have learned. My idea: Put a collision box around the chair like we did with the door. Once the player collides with the chair, text pops up saying hit the g key to grab the chair. If they hit g the chair pointer gets assigned to the player variable grabbing. Then as the player moves the player’s position is fed into the chair. The chair changes it’s position to the position being feed into plus a little offset so it isn’t in the player. Then hit g again and the chair gets dropped and the pointer in player is set to empty. I put some checks that you can only pick up an object if grabbed pointer is empty or something. I assumed there was a better way it waa just my quick guess after five mins of thought.

Oh right. Yeah, I use overlap events to pop help text too. Works well.

I’d recommend the physics handle for grabbing, though. Moving a grabbed object around with the player manually is a hassle, particularly if you want to obey physics.

But you can’t lose. Whatever you try, you’ll learn stuff! :slight_smile:

Privacy & Terms