Blueprint for opening a car door with a mouse click.

This must have been asked a million times already since more and more people are using UE for car configurators, however I am simply not getting any answers from anyone or finding any relevant tutorials. So here it goes:

I have a car configurator. I want to give the users the ability to click on the doors, hood and trunk and have it open. Then when done close. So basically approach the car, walk around then click on any door to open. Click again to close. Simple. Can anyone please be so kind and help in this regard? I can even pay for the tutorial or lesson if that is necessary. I watched a bunch of tutorials on casting, and scribbled a pseudo blueprint as you can see, but there are a bunch of errors obviously. Variables missing most likely and a few functions. All of the car components, including the mentioned movable doors and hood are in a blueprint form.


Hey @Przemek73!

You don’t want to use “Left Mouse Button” because that means “When left mouse button is clicked” instead of “When clicked on”.

Do you already have your project set up to use mouse interface? I can walk you through whatever I just need to know what you have already done and what you haven’t. :slight_smile:

What we’re going to need for this:

  1. Mouse interaction. This means a custom Controller and custom GameMode.
  2. On Clicked event with a timeline and a bool. :slight_smile:

This is what we’ll do for every one of the movable pieces.

The mouse controller and game mode setup can be found here:

It’s an old version but it should be 99% the same.

If you’ve got that I’ll walk you through the moving parts!

1 Like

It looks like you are close to the solution on your screenshot.

  1. that node “cast to player controller” which produces the warning should have the execute pin (that white line) connected, connecting nodes “left mouse button” > “cast to playercontroller” > “Branch”.

  2. When you break the hit result, a door is usually a component on a car actor, so you might be looking to connect the “Hit Component” property instead of the “Hit Actor”.

When done, how much of the code works?

Looks fine to me since there is a traced hit result under the cursor position when a click is done. That simulates the “clicked on”

I don’t remember if an input event is called across the project when activated (like a dispatcher) or if it would even work without connection to a controller… Just haven’t played around with it in that way. But even if it DID work like a dispatcher it’d still be bad to try to run them all at once seeing as this is only the door BP and there’s other doors plus the trunk. If they’re wanting to expand it beyond this like they’re wanting to explore it’d be a bad idea for scaling reasons… or it just won’t work period. I do think I remember doing it this way is a lot like a dispatcher.

All that said I should have looked more intently at the graph. @Przemek73 Roy’s right, you’re almost there with “Get Hit Result Objects Under Cursor For Objects”. I just personally think this code should not be ON the door Actor, it should be somewhere higher up in the hierarchy to call on an event in each individual piece. Maybe the car. You could really do it on the level, or even the gameMode.

But I’d use a BP_Interface to have it trigger the open/close EVENT on each piece, if they’re going to be individual actors.

That is a good point. Depends on the input routing. I’m not into the recent Enhanced Input and such additions, but the underlying system Slate handles input routing.

Basically it’s slightly different than the event dispatcher systems where registered events all just happen for a certain trigger. This is a routing system where X gets to handle input, and if not handled, Y gets a chance. The simplified version of who gets to do what when is directly documented on the link I posted above.

How developers often experience it, is that either their player controller, their UI, or their Pawn gets the input. This is crucial to decide where the “left click” event should be placed. The developer can check if the event is executed by placing a breakpoint ( F9 key ) on the Left Click node (it gets a red dot) and running the game. If the node is executed, the game will pause on it.

The car could be the Pawn and the door a component on the car. The PlayerController possesses the car. The left click event node is placed on the car. The door becomes a component on the car.

Thank you so much for responding. This is what I have so far.


I need this so that I can freely walk around the car, crouch and jump.
I also have these input actions:

Per your instructions I created the:

The initial blueprint I created is on the Door_LT. As you can see in the screenshot all of the parts that make up the car both exterior and interior are in BP form. So assuming I’m understanding you correctly each BP in this case Door_LT, Door_Rt, Hood_BEV and Decklid will have the same blueprint with obvious changes per BP/actor names.

Forgot to add that I had this really primitive blueprint for a keystroke to open all doors via an animation sequence as you can see in the screenshot:

I rearranged the CastToPlayerController → to → Branch and as you see the only warning I get is the CastToPlayerController which makes sense, because the target is Pawn and the Break Hit Result uses Hit Actor. Anyways take a look:

Nothing happens though when i play the sim, so there are obvious issues with the BP.