I have an Elevator Blueprint that is working perfectly, but now that I’m trying to add a line trace of what your looking at in third person it’s not seeming so functional.
-I have my “E”, “F”, and “R” keys set up as 1st, 2nd, and 3rd floors respectively.
-I am trying to get the buttons in the game to take place of that.
-Press “E” on the “2” elevator button when the character is within a certain distance to call the elevator move event is a scenario I’m trying to replicate.
I can’t seem to understand why I can’t make a line trace from my First Person Camera to my Elevator Button. Is it because it is a component of my Elevator Blueprint, which makes it inaccessible to the First Person Blueprint?
A couple of things:
-I don’t want to use the Level Blueprint or Matinee
-I am trying to keep the Blueprints self contained, so I can just drag and drop into another level.
a good start to get help would be posting pictures of your Blueprints, so we can see what is going on (:
In general, it should be totally working to trace the different components of the Elevator. Since you want
it selfcontained, you would need make sure that, after you traced one of the buttons (which are static meshs for example),
you have something to decide what button you hit.
Then you can easily determine what the Elevator should do.
One way would be make a function in the Elevator Blueprint that can take a component as Input and then, when you traced
the button and casted to the Elevator BPs, you can pass the “HitComponent” from the LineTrace to it via this function
and the Elevator can do the rest.
Okay, cool. I am posting photos of the stage. I am not sure how to tell the Line Trace in the FPS Blueprint that it should be casting to Elevator Blueprint Button2 Component. My only option is Elevator_Blueprint which would activate the MovetoFloor2 Event No matter where I’m clicking inside of the Elevator Blueprint. Any time I try to force the connection, it doesn’t understand the call event. What is your suggestion? Maybe there are some even types or something I’m unaware of. Also, the Right Mouse click node is connected when I’m trying to test it (Just FYI). Ha
One thing you had said was the make a function that can take a component as Input. I am not sure which nodes to call to make a component an input or how to make the component realize it is being line traced is specific. I would see it as the FPS, but how do I get the component of the Elevator to realize I’m hitting it? I can’t seem to pass the “HitComponent” to it because is having issues understand the casting. I always get compiling errors.
Make a function in your Elevator called something like “DetermineFloor”. Give it an Input variable of Type “SceneComponent (Reference)”.
When you trace with the Right Mouse Button (Remember to actually connect the Pressed Event to the Line Trace!), cast the “HitActor” to your Elevator
class. Call the “DetermineFloor” function then and pass the “HitComponent” over to it (HitComponent might need a cast to SceneComponent first :X).
Then, inside of the Elevator, give “DetermineFloor” some logic. Check if the passed Component is equal Button1, Button2 or Button3 and depending
on which is true, call the function you have to move the Elevator to that floor.
If you have trouble with casting, blueprint communication, inheritance etc, please watch this teaching stream of Epic Games: