Unity Transform
1 public class PlayerControll : MonoBehaviour 2 { 3 Transform playerTransform; 4 Animation playerAnimation; 5 Rigidbody playerRigidbody; 6 public float moveSpeed; 7 public float jumpAbility; 8 bool canJump; 9 10 void Start() 11 { 12 //playerTransform = gameObject.transform; 13 //playerTransform = this.transform; 14 //playerTransform = transform; 15 playerTransform = GetComponent<Transform>(); 16 playerAnimation = GetComponent<Animation>(); 17 playerRigidbody = GetComponent<Rigidbody>(); 18 Debug.Log(playerTransform.name); 19 } 20 }
12、13、14、15 都可以获取游戏对象的Transform。