- Home /
              This question was 
             closed Nov 10, 2015 at 07:23 AM by 
             ar4ta for the following reason: 
             
 
            Problem is not reproducible or outdated
How to Stop Transform.Position in X-axis = 0 ?
Excuse me, anyone know how to stop my gameObject Transform.Position if x-axis = 0 ? On this case, i'll make AR with Vuforia ImageTarget, and i want to stop this transform.position in the center of imageTargets...
This is my sample code i used :
     private TrackableBehaviour mTrackableBehaviour;
     private bool isRendered = false;
     private GameObject Mobil;
     
     void Start()
     {
         Mobil = GameObject.Find("Mobil");
         
         mTrackableBehaviour = GetComponent<TrackableBehaviour>();
         if (mTrackableBehaviour)
         {
             mTrackableBehaviour.RegisterTrackableEventHandler(this);
         }
         
         OnTrackingLost();
     }
     
     void Update()
     {
         if (isRendered && Mobil.transform.position.x < 140){
         Mobil.transform.position += Mobil.transform.forward * 10.0f * Time.deltaTime;
         }
     }
               Comment
              
 
               
              Answer by Pecek · Dec 30, 2013 at 04:48 AM
  if transform.position.x > target.position.x
  transform.position.x -= Time.deltaTime * speed
    
  if transform.position.x < target.position.x
  transform.position.x += Time.deltaTime * speed
This will cause jittering, but you get the idea.
Follow this Question
Related Questions
(Game.Name) unfortunately stopped working after going to another app 1 Answer
Check if a rigidbody has stopped moving for several frames. 2 Answers
App has stopped working in Unity 2018.2.4 0 Answers
Unity editor stopped working while importing package and open project 0 Answers
Crash At The Start Of The Game 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                