Changing depth of a SphereCollider without changing its size

I’ve been trying to change depth of a SphereCollider, so when the player goes through a checkpoint, it grabs it at the checkpoint position, not before it. Noone of the solutions from the web helped me yet and it’s getting kind of frustrating. That’s my code:

    void OnTriggerEnter (Collider other)
    {
        if (other.transform.tag == "Checkpoint")
        {
            SphereCollider sc = other.GetComponent<SphereCollider>();
            sc.transform.position = new Vector3(0, 0, 50);
            manager.AddCheckpoint();
            Destroy(other.gameObject);
        }
        if (other.transform.tag == "Goal")
        {
            Time.timeScale = 0f;
            manager.CompleteLevel();
        }
    }

So, what i was working with is basically this

SphereCollider sc = other.GetComponent<SphereCollider>();
sc.transform.position = new Vector3(0, 0, 50);

I tried to put some transform position in there, cause without it I get an error saying ,cannot convert type Vector3 to Collider".

Any help would be appreciated

Hi,

So what you want to do is when you get a trigger event, test how far the other object is from a plane running through the center of the the sphere. That way you know the collision is within the circle and then you know it’s also close to or intersecting it’s center cross section. Below is some simple code you could attach to the Checkpoint sphere with a sphere collider attached with isTrigger set to true

using UnityEngine;
using System.Collections;

public class Checkpoint : MonoBehaviour {

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}

	void OnTriggerEnter (Collider other)
	{
		CheckForCollisionSimple(other);
	}

	void OnTriggerStay (Collider other)
	{
		CheckForCollisionSimple(other);
	}

	bool CheckForCollisionSimple(Collider other)
	{
		// simple method measures distance from a plane running through the center of the checkpoint facing it's forward axis, to the center of the other object
		float distanceToTrigger = 0.1f;
		Plane crossSectionPlane = new Plane(this.gameObject.transform.forward, this.gameObject.transform.position);
		if(crossSectionPlane.GetDistanceToPoint(other.transform.position) <= distanceToTrigger){
			Debug.Log("The other object is within tolerance");
			return true;
		}
		return false;
	}
}

Once another object enters it calls CheckForCollisionSimple to see if it’s close to the plane, the important part is to also implement OnTriggerStay as that is call continuously while the other collider is inside the trigger. Which you need as is might not pass through the center plane the instant it enters the trigger.

An exercise I leave for you is calculating when the first part of the other object reaches the center plane, at the moment we test the transform.position of the other object, but that might not be the tip of the players nose for example.

PS
Remember the circle/ring you care about is facing the spheres forward/positive z axis as setup in the Plane constructor.

“Would love it to be a simple fix, but as far as I can tell making a circle mesh inside Blender and using it as a mesh collider is my best option?”
Yes. I think it’s a pretty simple fix don’t you?