티스토리 뷰
Update() 함수에 추가
if (isMoveState)
{
//Vector3 targetPos = transform.position + hitPosition;
Vector3 dir = hitPosition - transform.position;
Vector3 dirXY = new Vector3(dir.x, dir.y , 0);
//Vector3 targetPos = transform.position + (hitPosition - transform.position);
Vector3 targetPos = transform.position + dirXY;
Vector3 framePos = Vector3.MoveTowards(transform.position, targetPos, moveSpeed * Time.deltaTime);
Vector3 moveDir = (framePos - transform.position);// + Physics.gravity; // 땅에서 다닐거면 중력을 넣고, 하늘을 나는 비행기 일때는 뺀다.
cc.Move(moveDir);
Debug.Log("framePos : " + dir.y + " /// " + framePos + " targetPos : " + targetPos);
if (framePos == targetPos)
{
isMoveState = false;
Debug.Log("Stop");
}
}
else
{
}
if (Input.GetMouseButton(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo;
if (Physics.Raycast(ray, out hitInfo, 100f))
{
Debug.Log("hit point : " + hitInfo.point);
int l = hitInfo.transform.gameObject.layer;
//if (l == clickLayer)
{
Debug.Log(" hit object : " + hitInfo.collider.name);
hitPosition = hitInfo.point;
isMoveState = true;
}
}
}
}
'프로그래밍 언어 > 프로그래밍' 카테고리의 다른 글
[JAVA] 채팅 서버, 클라이언트 예제 (0) | 2016.10.02 |
---|---|
[JAVA] 스트림 입출력 형식 (0) | 2016.09.30 |
유니티 점프 (0) | 2016.06.08 |
해시 테이블 (hash table) (0) | 2009.01.18 |
트리 (0) | 2009.01.18 |
- Total
- Today
- Yesterday
- 서울시
- 유니티
- 지원
- 안드로이드
- 뜻밖의 샤워
- Linked List
- 임창정
- 청년몽땅정보통
- 신청
- 김광석
- 발생후
- 민경훈
- 축제
- 태풍발생
- 청년
- android
- 지원금
- 공모전
- 연결 리스트
- 혁오
- 유머
- 김광석 코드
- 문화
- 아이유
- 김광석 기타 코드
- 청년정책
- 서울특별시
- 고양이 깜놀
- 버즈
- 공연
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |