using UnityEngine; using System.Collections; public class Missile : MonoBehaviour {
public float missileSpeed = 5.0f; public float missileDelay = 0f; void Update () { Vector3 testVec = Camera.main.ScreenToWorldPoint(Input.mousePosition); - 스크린 좌표를 게임내 좌표로 변경 시켜주는 부분 testVec.z = 0f; - 2D용으로 만드는 경우 z값은 받아오지 않는다 iTween.LookUpdate(gameObject,iTween.Hash("looktarget",testVec,"time",20)); - 미사일이 마우스쪽을 바라 보도록 회전 시켜주는 부분 iTween.MoveUpdate(gameObject,iTween.Hash ("position",testVec,"time",missileSpeed)); - 미사일이 마우스쪽을 향하도록 일정한 속도로 이동시켜 주는 부분
} } |