lovevisss
2015-05-16 18:40
//SceneScript using UnityEngine; using System.Collections; public class SceneScript : MonoBehaviour { public GameObject Player; public GameObject camera; // Use this for initialization void Start () { camera = this.gameObject; } // Update is called once per frame void Update () { } void LateUpdate() { if (Player != null) { camera.transform.LookAt(Player.transform.position); } } } //test using UnityEngine; using System.Collections; public class test : MonoBehaviour { public int walkspeed; // Use this for initialization void Start () { GameObject.Find("Main Camera").GetComponent<SceneScript> ().Player = this.gameObject; } // Update is called once per frame void Update () { forward (); } void forward () { transform.position = transform.position + walkspeed * transform.forward*Time.deltaTime; return; throw new System.NotImplementedException (); } }
Camrea是GameObject上的一个组件,就是Component,不是一个GameObject
是的。Camera是GameObject.Camera
Unity3D快速入门
145914 学习 · 326 问题
相似问题