- Home /
 
               Question by 
               SolarStorm · Sep 04, 2016 at 09:53 AM · 
                androidobjecttouchmove object  
              
 
              Moving object away from newly created object created by script
Hey
I would like to move an object away from a newly created object which is created when i touch my screen.Here is my code so far but it doesn't work properly. How can i get it to work?Any help is appreciated.
Here is my code so far :
 using UnityEngine;
 using System.Collections;
 
 public class touch : MonoBehaviour {
 
     // Use this for initialization
     void Start () {
     
     }
     
     // Update is called once per frame
 
 public Transform target;
     void Update () {
         
         var speed = 3.0f;
             //if touched
             if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
                 var target1 = new GameObject();
                 transform.position = Vector3.MoveTowards(transform.position, target.position, speed*Time.deltaTime);
 
             
 
             }
     }
 
 
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How to Touch Drag 3D Objects 2 Answers
[Edited]-Android-swap position on touch 1 Answer
Android touch 3d Object event 1 Answer
How do I rotate an object on one axis to face android touch? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                