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;
}
}
CodePudding user response:
Checkpoint is a Collider data type. Try it with Checkpoint.transform.position
CodePudding user response:
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). If you want to move the Collider around, as mentioned in the documentation, you should attach a Rigidbody to it (probably a kinematic Rigidbody) and move it.