Question by
Veerababu.g · Mar 04, 2016 at 09:29 AM ·
positionmouselooktouches
How can i make my player to follow my fingar
as stated above i have a game object that has to follow my fingar. i write the code like
void Update () {
if (Input.GetMouseButtonDown (0)) {
Vector3 worldPoint = Camera.main.ScreenToWorldPoint (Input.mousePosition);
Vector2 touchPos = new Vector2 (worldPoint.x, worldPoint.y);
hit = Physics2D.Raycast(touchPos,-Vector2.up);
if (hit.collider != null) {
draging = true;
}
}
if (draging == true) {
touchFollow();
}
if (Input.GetMouseButtonUp (0)) {
draging = false;
}
}
void touchFollow(){
Vector2 fingurePos = Camera.main.ScreenToWorldPoint (Input.mousePosition);
transform.LookAt (fingurePos);
transform.Translate (Vector3.forward * speed * Time.deltaTime);
}
this is my code it's doing very greatly . but you you are not moving the fingar any where it's shaking . i know why this will happens but i can't solve it .....
plz tell me how can i modify it to achieve proper result.
thank you
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612070530im_/https://answers.unity.com/themes/thub/images/avi.jpg)