LoginSignup
0
0

More than 5 years have passed since last update.

【Unity】視点の移動

Posted at

大きな流れ

  1. GameObjectの取得とポジションの取得
  2. ポジションの変更

GameObjectの取得とポジションの取得

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class TimerAndMove : MonoBehaviour {
  GameObject camera;

  // Use this for initialization
  void Start () {
    camera = GameObject.Find("OVRCameraRig");  // GameObjectの取得
    pos = camera.transform.position;  // ポジションの変更
  } 

  // Update is called once per frame
  void Update () {
  }
}
  • OVRCameraRigはGameObjectの名前

ポジションの変更

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class TimerAndMove : MonoBehaviour {
  GameObject camera;

  // Use this for initialization
  void Start () {
    camera = GameObject.Find("OVRCameraRig");  // GameObjectの取得
    pos = camera.transform.position;  // ポジションの変更
  } 

  // Update is called once per frame
  void Update () {
    camera.transform.position = new Vector3 (pos.x , pos.y, pos.z + 10);
  }
}
  • この場合z軸方向に10ずつ移動し続ける
0
0
0

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