Finish level and match player transform with end goal. (Update)

Looking around the internet and I thought I’d found a fix, but it’s still not working.
I added a public variable for the EndTarget and used this line of code.

void OnTriggerEnter(Collider Triggers) {
		
		if (Triggers.tag == "obstacles") {

			isAlive = false;
			PlayerTransform.transform.Translate (target.transform.position);

Problem now is, the player get’s moved to a position that’s not of the target and the player still moves forward.
Also if the bool ‘isAlive’ is false, why is the forward movement still happening?

(old question) I’ve been at this for hours and have yet to come up with a solution. Once the player reaches the end goal I would like the player to match the end position and stop moving.

I looked into making the player a child of the end goal, but haven’t been able to get anything working.

Here’s the script.

	public float speed = 10;
	public float turnSpeed = 10;
	public float maxVelocityChange = 10;
	public float gravity = 10;
	public bool isAlive;
	public Text Score;
	public int CollectibleValue;

	//sounds
	private AudioSource source;
	public AudioClip Spark;



	private bool grounded;
	private Rigidbody _rigidbody;
	private Transform PlayerTransform;



	// Use this for initialization
	void Start () {
		
		StartLevel ();

		CollectibleValue = 0;
		
	}

	public void StartLevel(){
		
		PlayerTransform = GetComponent<Transform> ();
		_rigidbody = GetComponent<Rigidbody> ();
		_rigidbody.useGravity = false;
		_rigidbody.freezeRotation = true;


		isAlive = true;

		source = GetComponent<AudioSource> ();

	}
	
	// Update is called once per frame
	void FixedUpdate () 
	{
		
		if (isAlive) {
			PlayerTransform.Rotate (0, (Input.GetAxis ("Horizontal") * turnSpeed * Time.deltaTime), 0);

			Vector3 targetVelocity = new Vector3 (0, 0, speed * Time.deltaTime);
			targetVelocity = PlayerTransform.TransformDirection (targetVelocity);
			targetVelocity = targetVelocity * speed;

			Vector3 velocity = _rigidbody.velocity;
			Vector3 velocityChange = targetVelocity - velocity;
			velocityChange.x = Mathf.Clamp (velocityChange.x, -maxVelocityChange, maxVelocityChange);
			velocityChange.z = Mathf.Clamp (velocityChange.z, -maxVelocityChange, maxVelocityChange);
			velocityChange.y = 0;
			_rigidbody.AddForce (velocityChange, ForceMode.VelocityChange);


			_rigidbody.AddForce (new Vector3 (0, -gravity * _rigidbody.mass, 0));
		}	

		Score.text = CollectibleValue.ToString ();
	}





	void OnTriggerEnter(Collider Triggers) {
		
		if (Triggers.tag == "Endgoal") {

			isAlive = false;
                    // Here is where the player needs to stop and match the position of the end goal.

		}

As soon as it hits the trigger I have the isAlive bool to stop all movement, but right now it only stops the player’s control. The player character still moves forward.

How to stop the player from moving and match the player transform with that of the End goal?

Thanks for all and any help.

When you stop applying forces the physical object continue sliding because you do not change the velocity. It’s DIRTY but you can do that :

if (isAlive)
{
    // your code
}
else
{
    rigidbody.velocity = Vector3.zero
}