Trigger not triggering

Hello
I spawn a lot of objects into my scene randomly. They are all prefabs, with a collider, where the isTrigger variable is true. All items, have a itemscript, where the code to look for a trigger event with the player is. My character is a Rigidbody, and it’s collision detection is continuous and it also contains a collider.

The trigger code is the same as the reference, so I can’t see what i’m doing wrong :S

void OnTriggerEnter(Collider collision){
		if(collision.gameObject.tag == "Player"){
				Debug.Log("Collision");
				//code
Destroy(gameObject);
				
			}
			}

Bonus question:
I would also like to create a magnetic like effect, when my character is near an item. Should I use the Translate function to do that, or is there a better way?

Hope you can help me solve this :smile:

have you set the tag to player on your player gameobject?
I would go with the translate function as well for the magnetic effect.

try adding a rigidbody to the objects you want to run into?

Yes I have tagged my rigidbody character object with “Player”. Why should I add rigidbodies to the items, if they aren’t influenced by physics? I think it would cause huge amounts of unnessasary calculations for the computer…

it was just a suggestion, did you at least try it? if it doesnt help then thats fine, ive found that sometimes adding it fixes the issue of things not hitting eachother, good luck

LOL! Just solved it. It wasn’t the trigger, but just something in my script I forgot to turn on:smile: