Vector Math Translation

Hello all, I’ve got a vector math problem that I think might be easy to solve, I’m just missing an important piece. I have a laser gun that I’m using a niagara particle system to do the fx for. The laser it shoots is a continuous beam from the barrel of the gun (variable Shot Location) to where the player is aiming (variable Impact Point) that is fired until the trigger is let go. I have some fx that play as a result of the laser hitting an object at the end of the laser beam. To prevent the impact fx from ‘dragging’ when I move the beam across a surface and keep it locked to the end of the beam, I’m trying to keep the impact fx in local space of the niagara system.

This is where my problem is, I need to convert the position vectors of the shot location and impact point to local space. The laser starts at 0,0,0 in the niagara simulation, so that was an easy solve, but the end of the beam has been proving difficult. I need the position vector of the end of the beam to keep its offset from the start position. You would think subtracting the position of the start of the beam from the end would translate it to the coordinate space I need, right? But it’s providing wonky results.


The niagara system is spawned attached to the barrel of the gun, btw.

I assume the problem is my math. Greatly appreciative if anyone knows whats up.

  1. Get the World Transform: Use the Get Actor Transform node to retrieve the transform of the actor that will serve as the reference for the local space.
  2. Inverse Transform Location: Use the Inverse Transform Location node, which takes two inputs:
    Transform: Connect this to the Local Space Ref Transform node.
    Location: Input the world location vector (laser endpoint) that you want to convert to local space.
  3. Result: The output of the Inverse Transform Location node will be the location in the local space you need.
1 Like

Also be careful because your spawning attached to a point. The location you spawn has options to attach relative which will output relative space coordinates or attach keeping world location. If the parent attachment has a scale or rotation value it can affect the niagra vectors.

1 Like

I really appreciate the help! I had to do a little fanangling with how I spawned the niagara system like spawning it via an actor instead of a system, but this was precisely it.

1 Like