Last active
August 29, 2015 13:56
-
-
Save GOROman/8843733 to your computer and use it in GitHub Desktop.
Unity+OculusSDKでXboxコントローラの右アナログスティックの上下で高さを変えるサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class JoyY : MonoBehaviour { | |
public float power = 0.02f; | |
public Vector3 targetPos; | |
// Use this for initialization | |
void Start () { | |
targetPos = transform.localPosition; | |
} | |
// Update is called once per frame | |
void Update () { | |
float h = OVRGamepadController.GPC_GetAxis( | |
(int)OVRGamepadController.Axis.RightYAxis | |
); | |
Vector3 v = new Vector3( 0, h * power, 0 ); | |
targetPos += v; | |
// 必要ならクランプ | |
// targetPos.y = Mathf.Clamp( targetPos.y, -1.0f, 3.0f ); | |
// まったり反映 | |
transform.localPosition += ( targetPos - transform.localPosition ) * 0.1f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
これをアタッチしたオブジェクトの上・下の位置がXboxの右アナコンで変わります。