Announcement

Collapse
No announcement yet.

How do I set up a line trace to my Elevator Buttons in my Elevator Blueprint???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How do I set up a line trace to my Elevator Buttons in my Elevator Blueprint???

    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.

    Any help would be appreciated.

    -Ivy

    #2
    Hey there,

    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.
    Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

    My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
    (Including 100+ Pages Multiplayer Network Compendium to get you started.)

    Comment


      #3
      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.

      Click image for larger version

Name:	LineTrace1.png
Views:	1
Size:	149.0 KB
ID:	1101355

      Click image for larger version

Name:	LineTrace2.png
Views:	1
Size:	293.1 KB
ID:	1101356

      Click image for larger version

Name:	LineTrace3.png
Views:	1
Size:	310.3 KB
ID:	1101357

      Comment


        #4
        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:

        Open for contracted work | C++/BP (incl. Multiplayer) | Tutoring | VR

        My UE4 Blog/Page with Tutorials and more: Hit me for ALL the things!
        (Including 100+ Pages Multiplayer Network Compendium to get you started.)

        Comment

        Working...
        X