This is the only kind of Intersect I can find in C# - finding elements that two lists have in common, which is not anywhere close to having your main character intersect with something. What are you talking about?
It’s possible to write your own intersection-detecting code, but you might end up basically reimplementing a large part of a physics engine… when you’ve got a perfectly good physics engine just sitting there available for your use (that’s more performant than anything you’d be able to write, btw).
Any intersection-detecting code we would give you might be subject to any of the same problems that you might run into by simply using the physics engine, unless you can tell us the reasons you’re so dead-set on avoiding it.
If you don’t want them to be interactable like a physics object (like you don’t want the weapon on the ground to bounce around, fall over, etc), you just need to set the Kinematic property to true. But yeah, rigidbody is the answer you want.
I helped someone to write code you’re describing almost exactly. They used Triggers. They were picking up items in the world with a key (to add to their inventory).
Your original post amounts to: “I have two things over here and two things over there, how can I figure out how many things there are? Do NOT reply telling me to use addition.”
I’m 99% certain that you don’t want to use rigidbodies because you’re misunderstanding something about rigidbodies, because rigidbody+trigger is exactly 100% the answer to your question. The reason I asked why you don’t want to use them is to either help you fix this misunderstanding, or to learn something myself, because that would imply you have some bizarre edge case that actually rules out the usage of rigidbodies.
But if you’re going to ask for help on a forum and then reject help from that forum, enjoy not learning anything and not fixing your problem, I guess.
I was kinda going to say what StarManta wrote, in my own way/words. I got the feeling that you were opposed to rigidbodies, but you weren’t sure why. And you thought people were “forcing” you to do something you didn’t want, and not realizing that they were trying to help and not just ignoring your request. For fun, just try the situation with a Trigger + rigidbody. (yes, the person I helped included a rigidbody; it had to ** had to: much simpler)
@TheRedGuy90 I’ll be the one guy to offer an alternative solution. Sorry to resurrect perhaps an old thread.
You described:
You already stated you do not want to use rigidbodies, thus I guess you are using a character script that does not utilise the rigidbody component.
So, rather than even requiring colliders on your items…
Create a script (call it whatever you want) and drop it onto every item that can be picked up in the game. In this script’s Update() method, or a coroutine, you can check for the item’s distance to the player using Vector3.Distance.
Two variables are required: the Transform component of the player, and a float for how close you can get to the item before it gets picked up.
…Incase you don’t quite understand my wording (or anybody else):
public Transform Player;
public float distanceToCollect; // call this whatever you want
void Update () {
if (Vector3.Distance(Player.position, transform.position) <= distanceToCollect) {
// Pickup method here
Destroy(gameObject); // For keeping the playing field clean for performance
}
}