Use Mouse to interact with mesh in other blueprint?

I’m trying to allow my middle mouse wheel, when scrolled in one direction or the other, to push or pull a specific mesh away from or towards my camera. The mesh should only be allowed to move while I’m looking at it.

This is a picture of the level, except I have 10 more panels (they’re not included purposely because the textures contain sensitive information) that create a 3 row by 4 column matrix.


My solution thus far has been to take the player character’s camera and attach (as a child) a long, narrow box collider to it. See below:


My specific panel’s blueprint then has an OnComponentBeginOverlap event that responds when the camera’s box overlaps it. Upon overlap, I first set the rotation of the mesh to face the camera. Then, to make it so the panel is changing its distance to the camera based on my mouse wheel input, and to make sure it only activates this feature while I’m looking at it, I set a bool isColliding to true, which is attached to an event tick. I have an EndOverlap that changes the bool back to false. Below is picture of part 1 of this mesh’s event graph (white-out on overlap is deliberate):


In the following event graph pic (in the same blueprint as above) I set the mesh’s transform on begin play so I can return it there when I look away from it. To constantly interact with the mesh, my event tick branches with the IsColliding node to adjust the distance of the mesh to the camera based on the float multiplied against the forward vector, which I’m hoping to adjust by using my middle mouse button to raise and lower the index assigned to an array with 15 elements from 1 to 1400. Also, as you can see, when IsColliding is false (i.e. when I look away) the mesh resets to its original position.


Finally we have the PlayerController, which has the mappings for middle mouse scroll up and down (I’ll spare you the photo). I’m trying to to get these to interact with the indexes in each of the mesh blueprints. I’ve tried to do an interface, but I’m nearly certain I wasn’t doing it right.

I’ve been working on this longer than I care to admit, and would really appreciate some help if anyone knows how to solve this dilemma. Bonus points for a way to solve it without using an event tick for each blueprint mesh (as my current setup does).


Ok, I’m at work so I can’t look too closely at the images because it will become too obvious I’m not working :wink:

But first, let me make sure I have this right:

  1. When a player looks at the mesh, you want the mesh to rotate, matching the player’s yaw
  2. When the player uses scroll up or down, you want the mesh being looked at to move towards or away from the player.
  3. When the player turns away from the mesh, you want the mesh to return to its transform prior to any player interaction

Is that right?

The first thing that comes to mind is that you should be using a Single Line Trace from the camera rather than checking collision on a component child of the camera. Unfortunately, I think the only way to accomplish the goal of having whatever object the player is looking at face the player, you’ll need to use the event tick at least once, on the character blueprint when calling the single line trace.

Do you only have one blueprint mesh? Do you plan to add more? You can create an interface to make it easier to add more meshes later.

Here’s what I would do

  1. Create an interface
  • Right click in the content browser and create a new interface blueprint, call it “Mesh Interaction” or whatever. Add a new function, “LookAt”, with one input of type “rotation”. Add another new function, “LookAway” with no input.
    Add another new function, “Move” with a boolean input.
  1. Add the interface to your blueprint mesh
    In the blueprint mesh, go to blueprint properties and find the interface section. Add the “Mesh Interaction” interface.

  2. Create the functions for LookAt, LookAway and Move
    Create a new variable of type “Transform” to hold the actor’s initial transform.
    In the blueprint mesh’s event graph, add event “LookAt”. If the transform variable is not set, set it. Then set the meshes rotation to be what gets passed in from the output pin.
    Add event “LookAway”. Set the actor’s transform to be what is held in the transform variable.
    Add event “Move”. Use the boolean input to determine if it should move towards or away from the player. Could have it so true = towards, false = away. However you wanna do it.

  3. Create the “LookAt” function call in the character blueprint
    First, I would create a variable to hold an actor, I’m gonna call it “CurrentActor” because I’m creative like that,
    Add an event tick (because we need to check every frame what the character is looking at), and execute a Single Line Trace. One of the output pins is the “Hit” result. You can break this to get the actor that gets “hit” by the trace.
    I would then compare the actor hit by the trace to the “CurrentActor”. If it is the same, execute the actor’s “LookAt” function, passing in the current rotation of the character. If it is different, execute “CurrentActor”'s “LookAway” function, then set “CurrentActor” to be the actor hit (or if no actor is hit, need to find a good way to null out CurrentActor. The only decent way I’ve found to do this so far is to set it to some dummy actor… not ideal, but it works).

  4. Create the “Move” function call in the character blueprint
    Add an event that is called when the character scrolls the mouse wheel up and down.
    Get the “CurrentActor” and execute the “Move” function, passing in a true for moving up and a false for moving down.

Uhm… I think that about covers it. Might not be the best way to go about handing all this stuff, but based on my entire 1 month’s experience (lol) that’s how I’d do it.

Kinda like this?

Thanks a million for helping out. You are correct with your summary of what I’m trying to do. I tried to implement everything you mentioned, but I still don’t seem to be getting the blueprints to communicate. I’ll upload the blueprints I put together so you can see if I missed something. Also, to answer one of your questions, I have a total of 12 mesh blueprints that should all implement the interface and work in the same way.

Character Blueprint #1:

Character Blueprint #2 (the line going into the trace node comes from Event Tick):

Mesh Blueprint #1:

Mesh Blueprint #2:


You’ll notice in the second-to-last picture that I have a print string node after Event Look At. I was trying to see if the event was being triggered by the Event Look At function in the Character blueprint. That print string doesn’t print to screen, so it doesn’t seem to be.

One thing I didn’t know how to implement was your dummy actor suggestion. I just created a branch to see if an object was hit or not from the trace. Not sure if that does the same thing you mentioned.

Also, the move node says Target is ExplorationCharacter. Is that right? I would think the target is the other blueprint.

Two changes

I spotted two mistakes I made. I need to add Set Current Actor to Hit Actor after Look At fires (already have that for Look Away). Also, I see why you said I need a dummy actor: if I don’t the Current Actor will never trigger Look Away when I’m looking at nothing because it’s stuck on the previous actor and is still triggering Look At.

I still don’t get why the functions in my mesh blueprint won’t fire. I’m guessing it has to do with the Target in the nodes being wrong.

For those interested, I figured it out. As I suspected, I wasn’t using the right target, but I also wasn’t using the right interface function. You actually have to use the “message node”, which you can find by just typing in “message” in the auto-complete field. I got the right target by dragging a get for the box component into the blueprint and creating a GetOverlappingActors node from it. The array output for that was just plugged directly into the message node’s target input.

Now my new issue is that as the panel comes closer to me, I look more centered and the box then collides with both the intended panel and one behind it, triggering both. I wonder if there’s some ability for each mesh’s blueprint to not activate if the box collider is already colliding with something else that’s closer to the camera. Either that or I can make it so the box collider dynamically adjusts its length to be just slightly longer than the first panel it collides with–especially as the panel moves closer to me.

Edit: Also, if you’re wondering why I went back to the box collider tactic instead of tracing, it’s because the trace seems to misfire in the beginning when it first hits an object. For example, I put a print string just after a (true) branch from the hit output on trace. It will print “hello” about 5 times then it will go false for a single frame then back to true for the remainder. Certainly a bug if I’ve ever seen one. This wouldn’t work for my purposes because it resets my mesh to its original transform.