Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class theLastOneBehaviour : MonoBehaviour {
- private Vector3 clickPos; // vi tri click left mouse
- // Use this for initialization
- void Start () {
- clickPos = transform.position;
- }
- // Update is called once per frame
- void Update () {
- MovetheLastOne ();
- }
- void MovetheLastOne(){
- // bat su kien click chuot trai
- if (Input.GetMouseButton (0)) {
- // Camera.main.ScreenToWorldPoint --> Chuyen Toa do man hinh thanh toa do 3 chieu
- // Input.mousePosition --> Lay toa do man hinh
- clickPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
- }
- // di chuyen tu vi tri hien tai toi clickPos
- transform.position = Vector3.MoveTowards (transform.position, clickPos, Time.deltaTime * 3.0f);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment