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)
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.
If you bring a more specific use case I could probably help you figure out a more precise method! Get back with us soon!
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.
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.
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.
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.