using UnityEngine; public class Example : MonoBehaviour { public Vector3 playerPosition; void Start() { playerPosition = new Vector3(2.5f, 0f, -3.25f); } }
using UnityEngine; public class Example : MonoBehaviour { public Transform playerTransform; void Update() { playerTransform.position += new Vector3(0f, 0f, 1f) * Time.deltaTime; } }This code uses the Vector3 class to move an object's position by 1 unit on the z-axis every second using the Time.deltaTime variable to ensure consistent movement regardless of frame rate. The playerTransform object is a reference to the object's Transform component, which contains the position of the object.