NULL Location from GetHitResultUnderCursorByChannel

Having problems with geting mouse location from function GetHitResultUnderCursorByChannel or GetHitResultUnderCursorForObjects or LineTraceByChannel sometimes it’s returning 0, 0, 0 Hit Location.

Its not always, functions are working properly, mostly. And i have simple map without anything special. Trying to spawn NPC(character type) and select it with GetHitResultUnderCursorByChannel function by getting actor reference, and then send actor to mouse location.

Cant do NULL check because doing NPC moving with this Location data, and its just one click move, so if data 0, 0, 0 NPC will not move at all.

Seems like trace is not colliding with Landscape sometimes and return Hit Location 0, 0, 0.

And with regular actor it`s colliding every time.

Any ideas why it can be and how to fix it?

64749-asdasdf.png

If you are clicking on space or just in sky, it will return empty location or default (0,0,0) and problem is there… If you are making top down game , under your floor, add huge board which will catch mouse click events.

Post updated.

Updated post with images. Maybe i miss something in my setup? Seems like problem is not appear if i zoom in camera more closely to the landscsape, on MAX camera distance from the landscape 0,0,0 location appears more frequently.

can you post also mouse cursor trace script ?

I think problem is when you are clicking on higher camera distance it traces short line and it doesn’t hits the ground. I think you need to trace longer line to detect ground position, Wait, i will upload picture soon to show how to do this

But if it is short, i will get then 0,0,0 constantly, but it`s only sometimes.

Updated post again with another blueprint with dubug mode enabled. And when location is 0,0,0 it seems like “red rectangle” doesn`t apper on click location, here screen Imgur: The magic of the Internet

Updated post again with another blueprint with dubug mode enabled. And when location is 0,0,0 it seems like “red rectangle” doesn`t apper on click location, here screen Imgur: The magic of the Internet

Firstly, use ConvertMouseLocationToWorldSpace node, then try make everything, like on my picture. Lastly if sometime it will return location (0,0,0) change number 1000 with more, like 5000. Good luck

I think problem is in landscape. It has no collision detection in that place. But also we must try to check if there is math problem. So just add my script to your and update value of 1000 with 5000 and post results picture.

Imgur: The magic of the Internet same result.

Over here you can exactly see where 0 result http://imgur.com/G3vytrA

i had same result when the line was to short so increase length of trace line and check if trace location equals 0,0,0 don’t do anything. because it means trace was failed.

Last screenshot is with length 20000

What else i can do then?

Problem is that i want to send NPC to mouse location and if to do a NULL check then it will not go at all if it is NULL.

Updated post again. Seems like problem is definitely with Landscape collision, becasue regular Actor Cube no problems at all.

Ok let me explain. when you camera looks down it’s easy to detect ground because trace line with short length will detect ground hit, but when you rotate your camera line trace is increasing too and when you are making rotation with 90 degree and if you click far it wouldn’t detect the ground. So my advice will be make camera look down and if you want to send your npc somewhere just move camera to that location and hit there. Use camera controller like League of legends or dota. I have done that camera controller so i can teach how to do that

Thank you, but i want to really fix this problem right way.