Back with an update. I tried my best with @Everynone 's suggestion and I have something working although I think I’m not implementing it correctly probably because I didn’t understand it very well.
First of all, I wanted to clarify a bit why I’m using different ranges for Interaction and Attacking, maybe I’m thinking about this wrong.
The plan is to have an interaction range for picking up items, talking to NPCs etc. and an attacking range depending on what weapon I’m using. That way when I click an interactable, I move there and interact when I’m interaction range and when I click an enemy, I move towards him and attack when I’m in attack range ( for example, if I’m using a bow this range would be higher than a sword).
So I tried to follow your suggestions with using sphere collision to determine the Player Range.
- I created 2 spheres, one for InteractionRange and one for AttackRange.
*If I understand correctly, I should create 2 new object collision channels : interactable and enemy. I set my interactables to Interactable object type and my enemy to Enemy object type. Then I set the collision on the spheres to ignore all, but overlap the object type I want to interact with. Is this correct? I have no experience with adding new collision channels … *
- When I click , I check the object type, if it implements the interface I store it and check what it is. Then, I move there. Now is the part where I got confused, implemented something but this doesn’t look right to me ( it works though). Lets say if item is already in range, I check what’s already overlapping my sphere and compare with the clicked object, if it’s there I interact. If it’s not in range, once it overlaps with my sphere I check if it’s the clicked object and Interact. Here’s how I did it:
-Then same thing for attack range sphere
This doesn’t look right, does it? It works though, here’s the video :
Red sphere is attack range, green sphere is interaction range
Again, thanks for all the help so far, I now have 2 ways of doing this that both work just need to understand them better and refine them.