Interact basic questions.

buhu

New member
Hello again :)
First - How to make interact ability checks all the time if specific object is in range? - Automatic dont work.
Second - How to make it work only on closest object
Third - can I have couple interactables with different interactable id's on the same objects? - that dont seams to work too.

To give bigger picture - I use dialog system for interactions with NPC's, everything works well here but when I try to add second interact ability that should work automatically all the time (and detects on charactercast NPC's layer) its not working at all... when I move it higher than Converse ability in hierarchy then conversations dont work too.
Edited:
Maybe I ask wrong questions.
When I put two NPC's close there is already something checking the distance and selecting correct one... but this interact ability works on button pressed... and I want it to work all the time when NPC is in range AND on button press and then give different tasks on both states.
Please help...
 
Last edited:
1. You could use the Trigger or Spherecast object detection modes on the Interact ability (for Trigger you'd need a trigger collider on the target object/s).
2. Targeting the nearest object is not built in to the Interact ability by default, but you could recreate similar behaviour with the Trigger mode by adjusting the size of each trigger collider. It also wouldn't be hard to add this feature to DetectObjectAbilityBase (you could create your own subclass), e.g. for the Spherecast mode, use SphereCastAll and get the nearest object instead of just using SphereCast to get the first object found.
3. As long as your Interact abilities and Interactable IDs are all set up to match, I think this should be fine - although you may need to have them be on separate GameObjects, in which case you could just create an empty child GameObject and use that for the second Interactable.
 
What about that?:
"this interact ability works on button pressed... and I want it to work all the time when NPC is in range AND on button press and then give different tasks on both states."
 
btw how the hell is this working?

guy should type 2 in interactable id field but instead he typing value of 2 in ability int data and interactable id is set to -1 and this is still working... can you explain why?
btw 2. Why do you have comments disable on your tutorials?
 
What about that?:
"this interact ability works on button pressed... and I want it to work all the time when NPC is in range AND on button press and then give different tasks on both states."
If I understand correctly, you want something to happen automatically when the NPC is in range, and something separate to happen on button press? You could use 2 interact abilities, one Automatic with a spherecast and the other with Button Down. As I said before, as long as you match up all the Interactable IDs etc. there shouldn't be any conflicts. (Again I'm not 100% sure on this but you may need each Interactable to be a unique GameObject, but try it.)

btw how the hell is this working?

guy should type 2 in interactable id field but instead he typing value of 2 in ability int data and interactable id is set to -1 and this is still working... can you explain why?
btw 2. Why do you have comments disable on your tutorials?
You can set the Interactable ID to -1 if you want to ignore it, i.e. allowing any Interact ability to work with it. You only need to set them to >=0 if you want to restrict it to a specific Interact ability. Comments are disabled because that's what these forums are for :)
 
Top