Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Move my character where i touched

$
0
0
I had problems taking position of my touchplace , i'm getting Index out of bounds error and i cant get any movements , i'm new , help me please. Here's the script ; #pragma strict var amirpos : Vector3 ; var touchpos : Vector3 ; var parmak : Touch ; var camerapos : Vector3 ; var touchposcam : Vector3 ; var speed : float = 15.0f ; function Start () { } function Update () { amirpos = GameObject.Find("Amirr").transform.position; camerapos = Camera.main.gameObject.transform.position; touchposcam = Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position); touchpos = Vector2 ( touchposcam.x , touchposcam.y ); if(parmak.phase == TouchPhase.Began && Input.touchCount >0) { if(amirpos.x != touchpos.x) { transform.position = Vector3( (touchpos.x-amirpos.x)/speed , (touchpos.y-amirpos.y)/speed , camerapos.z-amirpos.z ) ; } } }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>