using UnityEngine;
using System.Collections;
public class Touch : MonoBehaviour {
public float speed = 3.0f;
private Vector3 target;
void Start()
{
target = transform.position;
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
target.z = transform.position.z;
}
transform.position = Vector3.MoveTowards(transform.position, target, speed * Time.deltaTime);
}
}
출처 : http://cafe.naver.com/unityhub
'Unity3D' 카테고리의 다른 글
유니티 인스펙터 순서대로 sort 방법 (0) | 2016.08.25 |
---|---|
4.6 터치 이벤트 (0) | 2015.09.10 |
Unity Sprite Zorder (0) | 2015.09.10 |
유니티 애즈 연동 (4) | 2015.06.26 |
Admob 연동 방법 (0) | 2015.06.26 |