3d骑行视角旋转
This commit is contained in:
parent
939084b074
commit
c8c27bd021
@ -248,9 +248,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
MoveElevationImage();
|
||||
BindDataSource();
|
||||
MoveCamera();
|
||||
time += 1f;
|
||||
}
|
||||
MoveCamera();
|
||||
MoveDistance();
|
||||
}
|
||||
private float cameraX = 0;
|
||||
private float cameraY = 0;
|
||||
@ -347,14 +348,28 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
ChangeView(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//移动摄像头和箭头位置
|
||||
//移动摄像头
|
||||
public void MoveCamera()
|
||||
{
|
||||
if (target != null)
|
||||
{
|
||||
target.transform.position = mainController.currentPlayer.currentPos; //player.transform.position;// new Vector3((float)Math.Round(player.transform.position.x,1), 0, (float)Math.Round(player.transform.position.z,1));
|
||||
if (mainController.Is3dView)
|
||||
{
|
||||
if(mainController.RotateLock && mainController.currentPlayer.Speed > 0)
|
||||
{
|
||||
Vector3 v = Vector3.zero;
|
||||
v.y += mainController.currentPlayer.currentRotation.eulerAngles.y + 160f; //target.transform.rotation = playerController.transform.rotation;//new Quaternion(playerController.transform.rotation.x, playerController.transform.rotation.y +1f, playerController.transform.rotation.z, playerController.transform.rotation.w);
|
||||
target.transform.DOLocalRotate(v, 1.5f, RotateMode.FastBeyond360);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//移动3d人物和箭头位置
|
||||
public void MoveDistance()
|
||||
{
|
||||
if (target != null)
|
||||
{
|
||||
if (!mainController.Is3dView)
|
||||
{
|
||||
Vector3 v = Vector3.zero;
|
||||
@ -363,17 +378,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//mainController.player.transform.localScale.Set(0.1f, 0.1f, 0.1f);
|
||||
player.transform.localScale = m;
|
||||
}
|
||||
else
|
||||
{
|
||||
//3d视角跟随人物转动
|
||||
//CameraVector.x = cameraX;
|
||||
//CameraVector.y = cameraY;
|
||||
//CameraVector.z = cameraZ;
|
||||
//target.transform.eulerAngles = CameraVector;
|
||||
Vector3 v = Vector3.zero;
|
||||
v.y += mainController.currentPlayer.currentRotation.eulerAngles.y + 160f; //target.transform.rotation = playerController.transform.rotation;//new Quaternion(playerController.transform.rotation.x, playerController.transform.rotation.y +1f, playerController.transform.rotation.z, playerController.transform.rotation.w);
|
||||
target.transform.eulerAngles = v; //.Set(0, playerController.currentRotation.eulerAngles.y + 160f, 0);// = new Vector3(0, playerController.transform.eulerAngles.y + 160f, 0);
|
||||
}
|
||||
target.transform.DOLocalMove(mainController.currentPlayer.currentPos, 0.5f); //player.transform.position;// new Vector3((float)Math.Round(player.transform.position.x,1), 0, (float)Math.Round(player.transform.position.z,1));
|
||||
//控制照片移动
|
||||
((RectTransform)arrow.transform).position = Camera.main.WorldToScreenPoint(target.transform.position);
|
||||
if (mainController.currentPlayer.Speed > 0 && mainController.isStart)
|
||||
@ -386,7 +391,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
}
|
||||
}
|
||||
//绑定数据源
|
||||
|
||||
public void BindDataSource()
|
||||
{
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
|
||||
@ -23,6 +23,7 @@ using ChartAndGraph;
|
||||
using UnityEngine.UI;
|
||||
using System.Diagnostics;
|
||||
using UnityEngine.SceneManagement;
|
||||
using DG.Tweening;
|
||||
|
||||
public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
@ -99,6 +100,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
void OnDestroy()
|
||||
{
|
||||
//MapUDPService.Dispose();
|
||||
TouchKit.removeAllGestureRecognizers();
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
}
|
||||
@ -170,6 +172,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
return CompetitionMobileArrow;
|
||||
}
|
||||
|
||||
public bool RotateLock = true;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@ -230,6 +233,26 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
|
||||
SceneManager.activeSceneChanged += SceneManager_activeSceneChanged;
|
||||
|
||||
#region 手势移动&PC鼠标的控制
|
||||
|
||||
var rotationRecognizer = new TKOneFingerRotationRecognizer
|
||||
{
|
||||
targetPosition = Camera.main.WorldToScreenPoint(target.position)
|
||||
};
|
||||
rotationRecognizer.gestureRecognizedEvent += (r) =>
|
||||
{
|
||||
RotateLock = false;
|
||||
DOTween.KillAll();
|
||||
if (Is3dView && IsPointerOverGameObject(r.startTouchLocation()))
|
||||
target.transform.Rotate(new Vector3(0, 1, 0), r.deltaRotation);
|
||||
};
|
||||
rotationRecognizer.gestureCompleteEvent += (r) => {
|
||||
RotateLock = true;
|
||||
};
|
||||
TouchKit.addGestureRecognizer(rotationRecognizer);
|
||||
|
||||
#endregion
|
||||
|
||||
//进入比赛
|
||||
if (competitionId > 0)
|
||||
{
|
||||
@ -243,7 +266,10 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
StartCoroutine(Init());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
float timer = 1f;
|
||||
bool clearLock = false;
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ public class TKRotationRecognizer : TKAbstractGestureRecognizer
|
||||
public event Action<TKRotationRecognizer> gestureCompleteEvent;
|
||||
|
||||
public float deltaRotation = 0;
|
||||
public float CurrentRotation = 0;
|
||||
public float minimumRotationToRecognize = 0;
|
||||
|
||||
protected float _previousRotation = 0;
|
||||
@ -115,6 +116,7 @@ public class TKRotationRecognizer : TKAbstractGestureRecognizer
|
||||
if( state == TKGestureRecognizerState.RecognizedAndStillRecognizing || state == TKGestureRecognizerState.Began )
|
||||
{
|
||||
var currentRotation = angleBetweenPoints( _trackingTouches[0].position, _trackingTouches[1].position );
|
||||
CurrentRotation = currentRotation;
|
||||
deltaRotation = Mathf.DeltaAngle( currentRotation, _previousRotation );
|
||||
_previousRotation = currentRotation;
|
||||
state = TKGestureRecognizerState.RecognizedAndStillRecognizing;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user