Teachers open the door but You must enter by yourself.

Open Media Lab.
オープンメディアラボ

馬のセットアップ

馬をスタート位置に配置

  1. Position を(0,0,300)に設定
  2. Box Colliderは不要なのでチェックを外す

プレーヤーの視点位置の調整

  1. XR Origin (VR) を Hourse の子に移動 Position をリセット
  2. 再生して XR Origin (VR) の位置を調整し、調整後の Position の値をコピー
  3. 再生を停止して XR Origin (VR) の Position に値をペースト

馬の走行

  1. 馬の機能を呈するスクリプト Horse.cs を作成し、Horse にアタッチ
    
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class Horse : MonoBehaviour
    {
    	CharacterController controller;
    	Animator animator;
    
    	public float speed = 7.5f;
    	public bool running;
    
    	void Awake(){
    		controller = GetComponent<CharacterController>();
    		animator = GetComponent<Animator>();
    		animator.SetInteger("Vertical", 1);
    	}
    
    	void Update(){//馬を前に進める
    		if(running){
    			var forward=transform.TransformDirection(Vector3.forward);
    			controller.Move(forward * speed * Time.deltaTime);
    		}
    	}
    
    	public void Run(){
    		running = true;
    		animator.SetTrigger("run");
    
    	}
    
    	public void Stop(){
    		running = false;
    		animator.SetTrigger("stop");
    	}
    }
    
  2. Mainという名前の空のオブジェクトを生成し、以下のスクリプトをMain.csという名前で作成し、アタッチ
    
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class Main : MonoBehaviour
    {
    	void Start()
    	{
    		GameObject.Find("/Horse").GetComponent<Horse>().Run();
    	}
    }
    
  3. VRで確認する

This site is powered by Powered by MathJax