public Vector3 position ;

Descripción

La posición del transform en el espacio del mundo.

The position member can be accessed by the Game code. Setting this value can be used to animate the GameObject. The example below makes an attached sphere bounce by updating the position. This bouncing slowly comes to an end. The position can also be use to determine where in 3D space the transform is located.

using UnityEngine;

// Use Transform.position to bounce a sphere. // The sphere and a quad are colored using materials.

public class ExampleScript : MonoBehaviour { Vector3 velocity = new Vector3(0.0f, 1.0f, 0.0f); float floorHeight = 0.0f; float sleepThreshold = 0.05f; float gravity = -9.8f;

void Start() { transform.position = new Vector3(0.0f, 1.5f, 0.0f); }

void FixedUpdate() { if (velocity.magnitude > sleepThreshold || transform.position.y > floorHeight) { velocity += new Vector3(0.0f, gravity * Time.fixedDeltaTime, 0.0f); }

transform.position += velocity * Time.fixedDeltaTime; if (transform.position.y <= floorHeight) { transform.position = new Vector3(0.0f, floorHeight, 0.0f); velocity.y = -velocity.y; } } }