How to get the transform of the last gameobject in a list.

Hey all.

having a bit of a brain block.

in short when i hit space, im trying to find the position of the last gameobject in a list, and instantiate a gameobject 1 unit behind the last one.

any help would be great.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;

public class _PlayerController : MonoBehaviour {

    // public List<GameObject> playerlist = new List<GameObject>();
    public GameObject playertest;

    public List<GameObject> playerList = new List<GameObject>();

    private float x;
    // Use this for initialization
    void Start () {
       // playerlist = GameObject.FindGameObjectsWithTag("Player");
	// Update is called once per frame
	void Update () {
        if (Input.GetKeyDown(KeyCode.Space))

            GameObject plcount = (GameObject)Instantiate(playertest, new Vector3(0, 0, 0), Quaternion.identity);


Good day.

You can do this:

int index = playerList.count;
Vector3 position = PlayerList[index].transform.position;