unity控制相机实现旋转缩放——触屏版(单指控制旋转,结束有惯性滑动,双指控制缩放,根据手指间距离变化程度控制缩放程度)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Test : MonoBehaviour
{
    public float pinchDist;
    private float zoomVelocity;
    private float targetDistance;
    private float minDistance = 3;
    private float maxDistance = 8;
    private float distance;

    public Transform car;
    private Vector3 TargetPoint;


    float x;
    float y;
    public float speed = 1f;
    float xSpeed = 30f;
    float ySpeed = 30f;
    public float angle;
    public float targetangle;
    public int yMinLimit = 40;
    public int yMaxLimit = 85;
    private float m_touchMaxDist = 20f;
    public Vector3 currentDirention;
    private bool keepMove;
    private float waittime = 3f;
    private bool m_autoRotation;
    private float smoothness = 0.16f;
    private readonly Vector2 m_fitScreenRes = new Vector2(2048f, 1536f);
    float roatspeedy;

    private void Awake()
    {
        currentDirention = transform.position - TargetPoint;
        angle = Vector3.Angle(currentDirention, new Vector3(0, 1, 0));
        targetangle = angle;
        float xFactor = m_fitScreenRes.x / Screen.width;
        Debug.Log(xFactor);
        float yFactor = m_fitScreenRes.y / Screen.height;
        Debug.Log(yFactor);
        xSpeed = xFactor * speed;
        ySpeed = yFactor * speed;
        m_touchMaxDist /= xFactor;
    }
    // Use this for initialization
    void Start()
    {
        TargetPoint = car.position;
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值