ぼっちプログラマのメモ

UE4とかUE5とかについて書いたり書かなかったり。

OculusRiftで女性目線から見るおっ◯いを再現

デバッグ用にカメラの当たりを可視化

OVRPlayerControllerのPrefabは便利ですが、StandardAssetsのFirstPerson~のように
カプセルを置いておくと分かりやすいな~と思ったので早速実装

実装前
f:id:pafuhana1213:20130901234534j:plain

実装後
f:id:pafuhana1213:20130901234540j:plain

分かり…やすくなった…と信じたい…
少なくとも、どの辺りにカメラがあるのは分かるように…


やったことは、「ForwardDirection」の子にCapsule描画と、
↓のコードで作ったスクリプトをぶち込んだだけ。

public Vector3 Center = Vector3.zero;
public float Radius = 0.0f;
public float Height = 0.0f;
public GameObject Parent = null;
public CharacterController ParentController = null;
	
// Use this for initialization
void Start () {
	// 設定されていない場合、親のgameObjectを取得
	if( null == Parent ){
		Parent = gameObject.transform.parent.gameObject;
	}
	// 対象のCharacterControllerを取得
	ParentController = (CharacterController)Parent.GetComponent( "CharacterController" );
}
	
// Update is called once per frame
void Update () {
	// 各パラメータを取得
	if( null !=  ParentController ){
		Center = ParentController.center;
		Radius = ParentController.radius;	
		Height = ParentController.height;
	}
	
	Vector3 scale = this.transform.localScale;
	scale.x = Radius / 0.5f;
	scale.y = Height / 2.0f;
	scale.z = Radius / 0.5f;
	this.transform.localScale = scale;
}

親のCharacterControllerからパラメータ取ってきて、TransformのScaleに反映しているだけ
超簡単!


おまけ(という名の本編)

f:id:pafuhana1213:20130902234751j:plain
д゚)…(カプセルの代わりに、Lat式のモデルを使って…)

f:id:pafuhana1213:20130902234946j:plain
д゚)…(下を見てみると…ちっぱい…)


f:id:pafuhana1213:20130902235406j:plain
( ゚∀゚)o彡°


公開:https://dl.dropboxusercontent.com/u/30427841/Unity_web/oppai.zip