transform.postition and gameObject doesn't seem to exist

Hi, I’m trying to create a UI button system to teleport the player around in 3D, but I’m getting errors on just about anything related to at least attempting to get the postition of the character or change it. The transform or Transform values have no subcodes or whatever you call it. I’m not sure why the errors are happening but does anyone have any ideas?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class ConsoleSystem : MonoBehaviour
{
    public GameObject characterLocation;
    public float CharacterSize;
    public float MaxCharacterSize;
    public float MinCharacterSize;
    [Space]
    public float posX = Transform.position.x; //this is errored out.
    public float posY;
    public float posZ;
    [Space]
     transform.position = new Vector3(posX,posY,posZ);
// This transform code above is completely errored out in my code


}

Can you put the errors that Unity gives you please

You can only access transform inside a function, such as Start() or Awake().

Also, in this context, the Transform instance (uppercase T in this case means class name) on this object will always be called transform (lowercase t means instance name where this MonoBehavior is located).

1 Like