- Home /
Question by
Arman · Dec 29, 2010 at 09:47 AM ·
touchunityiphoneiphonetouch
Moving An Object With Touch
for(touch in iPhoneInput.touches) {
if(touch.phase == iPhoneTouchPhase.Moved || touch.phase == iPhoneTouchPhase.Began) {
transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (touch.position.x, touch.position.y, 10));
}
}
I have found the above code from tutorial Moving An Object With Touch but its not working when I play game in Unity3D. Can some one please help me.
Comment
Answer by vmnoodel · Jun 30, 2014 at 08:59 PM
// Update is called once per frame
void Update () {
foreach(Touch touch in Input.touches) {
if(touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Began) {
transform.position = Camera.main.ScreenToWorldPoint(new Vector3 (touch.position.x, touch.position.y,10));
}
}
}
Your answer
Follow this Question
Related Questions
From Mouse To Iphone Touch Code 0 Answers
Cloud recognition in Vuforia 0 Answers
3d UI Using plane For all screens 0 Answers
How to execute the lookAt function here? 1 Answer
Camera Rotation Probleme with iPhone 0 Answers