Dynamic Interact Crosshair

Hi! I currently have a crosshair that ray casts to an actor the player is looking at and if it implements InteractInterface switch to the interact crosshair. But how can I make it if you cannot interact with that actor again, then don’t display the interact crosshair. (example: shows crosshair, interacts, hides crosshair)

Thank you!

Hi @RealCrypticVerse!

So there are a few things I can think of:
Remove the actor and put a static mesh in its place
Add a condition on the actor that the player checks for before changing the crosshair (like: bStopInteraction) and if that condition is True, stop the line before changing the crosshair. Then as part of an interact code set that as True. :slight_smile:

If you bring a more specific use case I could probably help you figure out a more precise method! Get back with us soon!

2 Likes

The above suggestion is good. I agree.

Also just in case, ive made an interaction plugin that is free and open source, and implements things like activating and deactivating interactions. With delegates to notify, so you can show and hide prompts and crosshairs.

If you want you can look at it, maybe it gives you ideas.

1 Like

@Mind-Brain

Yea, a more specific case is my Keypad actor.
On interacting it changes the camera to a camera on the actor. Then after entering the correct code, make it so you cannot interact with it again. In this case after entering the correct code do NOT show the interact crosshair when looking at it. (If the code is wrong it just returns the camera to the player and does nothing else).

Also (if I am understanding correctly), I can’t really do a stopInteracting boolean, because there are a ton of interactable actors of different types with different meshes and functionality.

Well, what comes to mind here is the idea of changing the collision channel of that type to “Ignore” so it can’t return a “block” and activate anymore, but you can still keep the collision overall.

IE:

Set Collision Response to Channel

Ignore
Visibility/Camera/whatever you’re using for the LineTrace detection.

Hope that helps! :slight_smile:

1 Like

I cannot really do that since its actors, not static meshes, and I specifically need the actors for more complex functions.

agree that’s what i do in my plugin. i have two collisions profiles. one for active and then no collisions for inactive.

i also have a collider box instead of using the regular mesh collider for flexibility.

everything has a collision profile. i use actors too.

the profile is on the component.

OK, so that means I have to change it for each component? Some of my actors have upwards of 20-30 components

yes and no.

if you have 20/30 components to have collisions that’s asking for perf issues.

you would need to enable/disable on the components that you want to collide.

like i said before, i use an additional collider so that i can mess with the interaction collision despite of the mesh collision, and also have actors with multiple meshes but only one collider.

you should have one collider per “object” that you want to interact to. per unit that needs to be activated deactivated. you can see it in the plugin i’ve shared, the class Interact.

as you can see activate and deactivate (called by setactivate) changes the collision profile.

the cinteract is a component that extends a box collider.

the interact actor has a cinteract and forwards that decision to de/activate

this is an example of an interaction with 2 meshes but only one cinteract component.

which has only one collider.

the meshes themselves don’t need/have collisions

because the cinteract it’s its own collision box, i can expand the box to a more suitable size, regardless of the size of the meshes. i have other more complex actors too.

this also helps in cases where you have an actor that needs to collide with the pawn (blocking its movement) but also interact. for me, it’s better to have two colliders for that and keep the collisions separate, since functionally they are separate. usually i use the mesh collision for blocking the pawn so i don’t need to add an extra collider. but if i had more meshes or a different shape, i’d add another separate collider.