No announcement yet.

Calling function in Line Traced object

  • Filter
  • Time
  • Show
Clear All
new posts

    Calling function in Line Traced object

    Im working on interaction between my Top down character and objects he is line tracing. The tracing works and im getting hits. Im not sure what to do next though. Im trying to get the hit actors Actor(The actor that contains the static mesh that is being hit) and then call a function in that actor.

    Why are you getting the mesh component and then getting the component's owner actor instead of just using the Hit Actor output from the line trace's Hit Result?

    In any case, to call functions you've defined on the hit actor, you need to:

    1. Cast the Actor to the class that implements the functions (e.g., Character or a custom Pawn class or some other Actor subclass you've defined); OR

    2. Use a BP interface that contains signatures for your desired functions, then have the actor class implement those functions; OR

    3. Create a custom Actor Component that implements the functions, add the component to your desired actor BPs, then on the hit actor, use Get Component by Class and call the functions on the resulting component instances (not the actor instances)

    They all have some advantages and disadvantages...


      Thank you, i got it working by casting to the Actor class.