trouble with a transform issue.

Hi
I am working on a trigger where the artist can decide if it should move or rotate and in what direction it should happen.

The X axis works fine, but when I try the Y axis (moveUp = true, moveRight = false) it seems to stop after 1 frame instead of the required distance.

var moveRight = true ;
var moveUp = false ;
var moveDistance = 1 ;
var effectTarget : Transform ;  // the object to move.

// This keep track of the objects position eatch frame.
private var moveCurrentPosition : Vector3;	 


function Update()
{
	// MOVE X AXIS
	if (moveRight)																											
	{
		if (moveDistance > 0)																								
		{
			if (moveCurrentPosition.x <= moveDistance)															
			{
				effectTarget.transform.Translate
				(Vector3.right * moveDistance * Time.deltaTime);		
				
				// Updating the position to work with next frame.	
				moveCurrentPosition =
				effectTarget.transform.position ;		
											
			}
		}
		
		// Stuff for moving in the oposite direction here (left).
	}
		
	// MOVE Y AXIS
	if (moveUp)																												
	{
		if (moveDistance > 0)																								
		{
			if (moveCurrentPosition.y <= moveDistance)															
			{
				effectTarget.transform.Translate
				(Vector3.up * moveDistance 	* Time.deltaTime);	
				
				moveCurrentPosition = 
				effectTarget.transform.position ;											
			}
		}
		
		// Stuff for moving in the posite direction  here (down).
	}
}

Ok I found out I am moving my object a distance measured from the world origin and not my object its origin so when it is already past the distance I want it to move it shows this behavior.
I am not quite sure yet how to fix this.

I guess there is no easy way to tell it to move x distance from its current position,

So I have to get the current position and add it to the desired move distance, that seems to work.

I’m not really good at reading and deciding on what to do on scrips, but, I looks like, to me, that you diden’t assign the variables to there type. Try:

var moveRight :boolean = true ;
var moveUp : boolean = false ;
var moveDistance : int = 1 ;
var effectTarget = Vector3(0,0,0) ;  // the object to move.

// This keep track of the objects position eatch frame.
private var moveCurrentPosition : Vector3;   


function Update()
{
   // MOVE X AXIS
   if (moveRight)                                                                                 
   {
      if (moveDistance > 0)                                                                        
      {
         if (moveCurrentPosition.x <= moveDistance)                                             
         {
            effectTarget.transform.Translate
            (Vector3.right * moveDistance * Time.deltaTime);      
            
            // Updating the position to work with next frame.   
            moveCurrentPosition =
            effectTarget.transform.position ;      
                                 
         }
      }
      
      // Stuff for moving in the oposite direction here (left).
   }
      
   // MOVE Y AXIS
   if (moveUp)                                                                                    
   {
      if (moveDistance > 0)                                                                        
      {
         if (moveCurrentPosition.y <= moveDistance)                                             
         {
            effectTarget.transform.Translate
            (Vector3.up * moveDistance    * Time.deltaTime);   
            
            moveCurrentPosition =
            effectTarget.transform.position ;                                 
         }
      }
      
      // Stuff for moving in the posite direction  here (down).
   }
}

I may be wrong, however.

I figured it out,
the IF comparisation to move left or right differs when you are have positive values of negative values.

So I had to make:
a move right for positive values,
a move left for positive values,
a move right for negative values,
a move left for negative values.

And some checks to figure out the one thats required for the desired movement.