allowing a collision script to detect collision from multiple objects with the same name

hi, i have a script im using to detect if my character hits a certain object called are you seen, and right now
the script can only let my character detect collision with one object called are you seen. is it possible to let my character detect collision and teleport where he supposed to go every time he runs in to ANY object name are you seen? here is my current script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class found: MonoBehaviour
{

void OnCollisionEnter(Collision collision)
{
    if (collision.gameObject.name == "are you seen")
    {

        transform.position = new Vector3(3.9f, 3.05f, 64.8f);

    }

   
    

}        

void Start()
{

}

void Update()
{

}

}

Use tags to mark each of your different objects. Instead of “name” use “tag” like below for your character to teleport wherever once he hits whatever object you want. Personally, I would use OnTriggerEnter function and attach it to the player. Then, whenever the player comes into contact with it, his position can change.

private void OnTriggerEnter(Collider collider)
{
    if(collider.gameObject.tag == "Are You Seen")
    {
        // whatever your teleportation code is
    }
}

Make sure to add a new tag named exactly the same as what you have in the condition or else it won’t work.

Haven’t tested it and still a beginner myself but see how it goes.
Hope it works.

Thank you! this script looks perfect and i added an are you seen tag to the objects but now a complier error says "cannot convert a double to a float. do you know what that means? and am i supposed to put is trigger checked of my players rigidbody?

Probably that’s because you are passing a double somewhere where it takes a float.
Try adding an f after that number.

Example:
Vector3(1.2f, 2.3f, 3.4f)

If that does not help, maybe post a portion of the script that gives you the error message to investigate further.

Also some optimization recommendations:
If you are always teleporting the object to the same location, instead of using every time a new Vector3(3.9f, 3.05f, 64.8f) you can cache it first and then use the same variable each time.

Just doing collision.name or collision.tag will do, no need to get a gameObject first.

Answering your other question.
You do need is trigger checked, It can be on just one object or both, depending on your needs.