EnhancedTouch
というわけでスライドで発射するように適当に作ってみた
foreach (var touch in Touch.activeTouches){
switch (touch.phase){
case TouchPhase.Began:
touchPos = touch.screenPosition;
break;
case TouchPhase.Moved:
Debug.Log( $"Touch: Id {touch.touchId} Position {touch.screenPosition} Phase {touch.phase}\n" );
break;
case TouchPhase.Ended:
Vector2 shoot = (touch.screenPosition - touchPos);
shoot.Normalize();
Launch(shoot); // Launchは引数に発射方向を与えるように変更した
break;
}
}
スライド方向に出るので、手裏剣の場合はこういう感じなのかな。
このままだとタッチするだけでも弾が出てしまうので、shootの長さが一定以上の場合みたいなのを入れないとダメっぽい。
Vector2 shoot = (touch.screenPosition - touchPos);
if( shoot.magnitude > (Screen.currentResolution.width/3) ){
Debug.Log(shoot.magnitude + "/" + Screen.currentResolution.width/3);
shoot.Normalize();
Launch(shoot);
}
適当にスクリーンの1/3にしたら、なんとなく動いた。
今回は短いけど次は、ここ参考に指でなぞったところ(というか、始点と現在位置)に線を引きたい。