Quantcast
Channel: Answers by "IvovdMarel"
Viewing all articles
Browse latest Browse all 145

Answer by IvovdMarel

$
0
0
Start from this? float speed = 0.01f; float distance = 0; Vector3 mousePos; void Update () { if (Input.getMouseButtonUp(0)) { mousePos = GetMousePosHit(); } if (distance >= 1) { distance = 1; return; } Vector3 newPos = Vector3.Lerp(transform.position, mousePos, distance); distance+= speed; } void GetMousePosHit () { Raycast ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if(Physics.Raycast(ray, hit)) { return hit.point; }

Viewing all articles
Browse latest Browse all 145

Trending Articles