character is hiding behind a cover so he is barely visible
I want to click on this character to select it
but also I want that when I hover over the cover actor, it generates a hover event so I can see the cover’s characteristic (for example, how strong it is)
The collision on the cover actor blocks visibility. Therefore, it successfully generates a hover event. If I change this setting to Overlap or Ignore, it allows me to click on the character but I lose the possibility to get the information about the cover.
Is there a possibility for all the actors that stay on after another under the cursor to generate hover/click events?
That’s a tricky question.
Let’s say we take Dota2, where multiple actors may be under the cursor at the same time, but there’s priority set for them, so depending on the action, this or that character will be affected.
You can use multi line trace to trace multiple actors under the cursor, but how you choose with which to interact is really the question.
Thanks for pointing to multi line trace. Will try to figure out if I can use it for my case.
Regarding your question. As these are different kinds of actors, they have different event handlers. For example, if I hover over a cover, there should be an information panel on the right side of the screen. If I hover over the character, there is an info panel at the bottom of the screen. As I need only the character to take clicks, there is no confusion for the player about what is going on.
The problem with the multi line trace is that you have to handle hover/clicked/released separately with a complex set of blueprints.
I wondered if there is a possibility to allow an actor to collide with the cursor and at the same time to allow the actor behind to collide with the cursor. So all the code written for hover/clicked/released events are handled in the same way as if there is only one actor colliding with the cursor.
I know how to use interfaces but I can’t imagine where this interface should be and how it might look like so all the mouse-related events can work both for covers and the characters behind them.
I don’t think you get multiple actors when you use Get Hit Under Mouse Cursor, but if you use Multi Line Trace For Objects, you can get all the objects the trace hits, and it will go all the way to the end instead on stopping on the first hit. It will return the array of all the hit objects, and if they implement the same interface, you can interact with all of them in the same way through that interface.
Hey there @Anti_KoS! This may not be the cheapest way, but it’s definitely the most extendible. One way to make it less heavy would be to only call the multitrace when you get an event such as the normal hover colliding with something that could be selected (older games forced you to use like a magnifying glass or something to trigger inspect mode but context is key these days.
So basically Hover calls back to a bool that allows the multitrace, that then sends info back to your context handler. So like you say, if you click and there’s cover and a player, the player is the only one that needs the click, so the context handler handles that and sends off the events to whatever is needed.
The alternatives are how some other games do it, and I’ll list some examples.
Rimworld: First click gets the topmost/closest Z item/object no matter what. Second click and all subsequent ones in short succession in the same spot start a trace back to every item in that spot, and starts cycling through selecting them. This is less contextual however.
Insert RTS: Fully contextual most of the time. Left click a friendly thats also sitting on resources? You select the friendly. Left click an enemy while you have a friendly selected? They attack. Enemy is standing on resources? Still attack. Some game types allow you to handle all actions contextually, but others will inevitably need some abstraction/decision on how you want to handle the scenario.