LoginSignup
0
0

More than 3 years have passed since last update.

Unity メモ

Last updated at Posted at 2020-06-29

キー入力

Input.GetKeyDown( KeyCode.Space );

カメラをプレイヤーに追従させる

CameraController.cs
public class CameraController : MonoBehaviour
{
    GameObject player;

    void Start()
    {
        this.player = GameObject.Find("player");
    }

    void Update()
    {
        Vector3 playerPos = this.player.transform.position;
        transform.position = new Vector3( transform.position.x, playerPos.y, transform.position.z );
    }
}
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0