I think you got a Fundamental missunderstanding how Linetrace works. If you trace by Channel Visibility as example it will return you the first thing you hit that Blocks on that Channel. It can be anything you mentioned above. Base your Logic on the Hit Result you recive.
hi,
is there a way to prioritize the raycasting ? i only find line trace by channel (no chance to set channels) or get hit result under cursor by channel.
im trying to achieve the following:
- constantly raycast from mouse to world position (its a top down game)
- If the mouse is over GUI cancel the rest
- When the ray hits a character ( ally, enemy, npc, etc.) trigger an event (mouse is on an enemy with the details)
- If there is no character, the ray should look for interactables (items, in game triggers for puzzles etc.) when found, again trigger an event
- if none of the above was found, look for navigatable area. when a non-walkable area is clicked calculate the nearest walkable area and fire the event
any help is appreciated.
oh okay. so how do i prioritize the resut then ? I want the trace fire events in an exact order
Imagine there are enemies and items in the same place. I want to prioritize the enemy when Im casting a spell.
Why would you do any Priority? You only hit one thing at a time and never get multiple results back. Or do you want your trace trigger absolutly everything it hits on its full length? The first thing it hits is your Priority
You gotta be more precise than that. You still hit one or the other first. You make it sound like you want to hit a Point and than get everything around that Point in a certain Range to then choose what is in that range to prioritize. Is it that what you are looking for?
Same is true for Channels. You get something back you hit (anything rly) and you can filter your results down via Casting, Interface Calls or whatever you preffer. Maybe this helps you out? Collision Filtering - Unreal Engine
no. i think I am just too confused about it as I moved from unity. There i would cast a ray from camera to the mouse world position, check layers in an array. But i just read that I could use Trace for objects and try to cast to object types to find out what has been hit.