Cannot convert vector3 to collider?

Viewed 39

I'm trying to make a 3D racing game on Unity and I am currently looking to program checkpoints. Right now I have hit a roadblock in which I can't convert vector3 to collider. Any advice?

private void OnTriggerEnter3D(Collider Checkpoint)
    {
        if (Checkpoint.tag == "Checkpoint")
        {
            Checkpoint = transform.position;
        }
    }
2 Answers

Checkpoint is a Collider data type. Try it with Checkpoint.transform.position

A Collider is not at all a Vector3. I invite you to read the documentation for both types to understand better what each is used for.

As mentioned in another comment, if you want to access a Collider position, you should use Collider.transform.position (so

Checkpoint.transform.position

in your case). A Collider component should be attached to the object your rigidbody is supposed to collide to. If you want the Collider to respond phisically to impacts, as mentioned in the documentation, you should attach a Rigidbody to it.

Related