Question by
kkhkim2002 · Mar 16, 2018 at 07:23 AM ·
swipe
unity mobile touch swipe camera,mobile camera swipe control..
Hi Gentlemen I am a student studying mobile games. But I had a problem. The problem is that you can not touch swipe. I do not know what to do. I want to rotate 360 degrees based on the character. I want to see the angle with the character while looking at the character at a slightly distant camera angle. Help me, gentlemen.
Comment
Answer by kkhkim2002 · Mar 16, 2018 at 08:02 AM
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class MouseCamera : MonoBehaviour { public float sensitivity = 5.0f; public float smoothing = 2.0f;
Vector2 mLook;
Vector2 smoothV;
public GameObject Player;
// Use this for initialization
void Start()
{
Player = this.transform.parent.gameObject;
}
// Update is called once per frame
void Update()
{
var md = new Vector2(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
md = Vector2.Scale(md, new Vector2(sensitivity * smoothing, sensitivity * smoothing));
smoothV.x = Mathf.Lerp(smoothV.x, md.x, 1f / smoothing);
smoothV.y = Mathf.Lerp(smoothV.y, md.y, 1f / smoothing);
mLook += smoothV;
transform.localRotation = Quaternion.AngleAxis(-mLook.y, Vector3.right);
Player.transform.localRotation = Quaternion.AngleAxis(mLook.x, Player.transform.up);
if (mLook.y <= -40)
{
mLook.y = -40;
}
if (mLook.y >= 40)
{
mLook.y = 40;
}
if (mLook.x <= -180)
{
mLook.x = 180;
}
if (mLook.x > 180)
{
mLook.x = -180;
}
}
} it is Pc. moblie please.. XD