SDamnation
SDamnation

Reputation: 41

How to shoot ray in specific direction in UE4?

I'm trying to draw a debug line of certain length starting at my pawn position and moving in direction of mouse click, but I keep getting really weird results. Sometimes it works, but mostly does not. Seems like it depends on my character's location. blueprint: https://i.sstatic.net/RSGyb.jpg screenshots: https://i.sstatic.net/oUP3I.jpg

Upvotes: 0

Views: 1138

Answers (1)

Bas in het Veld
Bas in het Veld

Reputation: 1322

Your problem is that your ray trace starts at a (correct) world location, but it ends at a relative location, since you're multiplying the X and Y coordinates of a unit vector by 500 - this will result in a value between (-500, -500, 0) and (500, 500, 0)

Instead, you want to add your multiplied unit vector to your line start location, which will give you a world location.

Upvotes: 2

Related Questions