Hi ~
I Make Some app Turn around camera at some Object in Windows 7 Touch Screen.
But , I can’t receive Touch value in windows 7 Screen.
I used Input.GetTouch(0)…But I doesn’t Work
Here is cord doesn’t work
using UnityEngine;
using System.Collections;
public class MainAround : MonoBehaviour {
public Camera cam;
public Vector2 rotationVelocity;
public Transform[] target;
private int index = 0;
public bool touchOn = false;
public int zoomIn =22;
public int normal =60;
public float smooth = 5f;
private bool isZoomed = false;
private Component script;
private RaycastHit Hit;
public GameObject UI;
void Awake()
{
}
void Start ()
{
cam = GetComponent<Camera>();
}
public void HouseIn()
{
index = 1;
isZoomed = true;
//cam.GetComponent<MainAround>().enabled = false;
}
public void Main()
{
index = 0;
isZoomed = false;
}
void rayCasting(Ray ray)
{
if (Physics.Raycast (ray, out Hit, Mathf.Infinity))
{
if (Hit.collider.gameObject.CompareTag ("House")) {
HouseIn ();
UI.SetActive(true);
}
// if (Hit.collider.gameObject.CompareTag (“Main”)) {
// Main ();
// }
}
}
// Update is called once per frame
void Update ()
{
if(touchOn == false)
{
float camY = cam.transform.position.y;
bool clickingButton = false;
if(!clickingButton && (Input.GetMouseButton(0) || Input.GetMouseButton(1))){
rotationVelocity.x += Mathf.Pow(Mathf.Abs(Input.GetAxis("Mouse X")),1.5f) * Mathf.Sign(Input.GetAxis("Mouse X"));
rotationVelocity.y -= Input.GetAxis("Mouse Y") * 0.04f;
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
rayCasting(ray);
}
if (touchOn == true)
{
if (TouchPhase.Began == Input.GetTouch(0).phase | TouchPhase.Moved == Input.GetTouch(0).phase)
{
Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);
rayCasting(ray);
Vector2 screenPos = Input.GetTouch(0).deltaPosition;
Debug.Log(screenPos);
rotationVelocity.x += Mathf.Pow(Mathf.Abs(screenPos.x),1.5f) * Mathf.Sign(screenPos.x);
rotationVelocity.y -= screenPos.y * 0.04f;
}
}
camY += rotationVelocity.y;
cam.transform.RotateAround(target[index].transform.position, Vector3.up, rotationVelocity.x );
rotationVelocity = Vector2.Lerp(rotationVelocity, Vector2.zero, Time.deltaTime * 10.0f);
camY= Mathf.Clamp(camY, 0.0f , 5.0f);
transform.LookAt(target[index].transform);
if(isZoomed == true)
{
cam.camera.fieldOfView = Mathf.Lerp(cam.camera.fieldOfView,zoomIn,Time.deltaTime*smooth);
}
else{
cam.camera.fieldOfView = Mathf.Lerp(cam.camera.fieldOfView,normal,Time.deltaTime*smooth);
}
}
}
}
This cord is good work on Mouse (Mouse X)
But Doesn’t Work Touch Screen…ㅠㅠ
Smart Friends ~~~ Please Help me ~~~~