3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Unity5ハコスコVR開発 一人称視点のシューティングゲーム(FPS)の銃みたいに objectを配置したい、イージングでついてくる。

Last updated at Posted at 2016-07-05

こんな感じで常に前面に潜水艦いさせたい。

スクリーンショット 2016-07-05 18.01.11.png

1.空のGameObjectを作成(playerWrapと仮名)

2.下記、PositionControll.cs をアタッチ。
m_CameraTransformにはMainCameraを設定

hoge.cs

using UnityEngine;
using System.Collections;

public class PositionControll : MonoBehaviour {

	public Transform m_CameraTransform;

	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
		EasingMove();
	}


	void EasingMove(){

		// pos
		Vector3 diff = m_CameraTransform.position - transform.position;
		transform.position += diff * 0.05f;

		transform.rotation = Quaternion.Slerp (transform.rotation, m_CameraTransform.rotation, Time.deltaTime * 3f);
	}
}



3.常にカメラ前面にいてほしいオブジェクトを
(今回は潜水艦)をplayerWrapの子要素にする。

スクリーンショット 2016-07-05 18.08.34.png

4、位置調節。
playerWrap、常にカメラ前面にいてほしいオブジェクトのpositionを一度0.0.0にする。

その後、常にカメラ前面にいてほしいオブジェクト(ここでは潜水艦)の位置を画面右下に調節。

5、プレビューして確認。

(デバック方法)
Player Settings を開き(menu: Edit > Project Settings > Player)、 Other Settings を選択し Virtual Reality Supported のボックスをチェックすると、実行時にaltを押しながらドラッグすると視点を動かすデバックができる。

完 

3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?