How to get diagonal movement using Character.Move?

I will try to use this thread for my questions, since I don't want to create a bunch of them. Right now I don't know how to get Diagonal movement, right now I can only go up or down or left or right. I was thinking of making a movementX and movementY vector, then putting those together in a wholeMovement Vector, then using character.Move(wholeMovement) but that didn't work... anyone have any ideas?

Code: Code:

@script RequireComponent( CharacterController )

// This script must be attached to a GameObject that has a CharacterController var moveTouchPad : Joystick; var jumpTouchPad : Joystick;

private var moveWalk : System.Boolean; private var faceLeft : System.Boolean; var charMain : GameObject; var charSprite : PackedSprite; var forwardSpeed : float = 4; var backwardSpeed : float = 4; var upSpeed : float = .5; var downSpeed : float = .5; var jumpSpeed : float = 16; var inAirMultiplier : float = 0.25; // Limiter for ground speed while jumping

private var thisTransform : Transform; private var character : CharacterController; private var velocity : Vector3; // Used for continuing momentum while in air private var canJump = true;

function Flipper() { if (faceLeft == true) { charMain.transform.localScale.x = -1; }

if (faceLeft == false) {

charMain.transform.localScale.x = 1;
}

}

function PlayAnimation() { }

function Start() { // Cache component lookup at startup instead of doing this every frame

thisTransform = GetComponent( Transform );
character = GetComponent( CharacterController );

// Move the character to the correct start position in the level, if one exists var spawn = GameObject.Find( "PlayerSpawn" ); if ( spawn ) thisTransform.position = spawn.transform.position; }

function OnEndGame() { // Disable joystick when the game ends

moveTouchPad.Disable();

jumpTouchPad.Disable();

// Don't allow any more control changes when the game ends this.enabled = false; }

function Update() { //declare function variables var movement = Vector3.zero;

var isWalking = true; // end

//for loop to play script once if (moveWalk == true) {

 if (isWalking == true) { 
      charSprite.PlayAnim("walk"); 
      isWalking = false; 
 } 

} else { if (!isWalking) { charSprite.StopAnim(); isWalking = true; }

} //end

//move up if (moveTouchPad.position.y > .3) { movement = Vector3.forward * upSpeed; moveWalk = false; }

//move down if (moveTouchPad.position.y < -.3) { moveWalk = false; movement = Vector3.forward * downSpeed * -1; Flipper(); }

//stay still if (moveTouchPad.position.x < .1 && moveTouchPad.position.x > -.1 && moveTouchPad.position.y < .1 && moveTouchPad.position.y > -.1) { isWalking = false; moveWalk = true; }

//move left if (moveTouchPad.position.x < -.3) { faceLeft = true; moveWalk = false; movement = Vector3.right * backwardSpeed * -1; Flipper(); }

//move right if (moveTouchPad.position.x > .3) { movement = Vector3.right * forwardSpeed; faceLeft = false; moveWalk = false; Flipper(); }

// Apply movement from move joystick

// Check for jump if ( character.isGrounded ) {

  var jump = false; 
  var touchPad = jumpTouchPad; </p>
  if ( !touchPad.IsFingerDown() ) 
     canJump = true; 

   if ( canJump && touchPad.IsFingerDown() ) 
   { 
     jump = true; 
     canJump = false; 
   }    

  if ( jump ) 
  { 
     // Apply the current movement to launch velocity        
     velocity = character.velocity; 
     velocity.y = jumpSpeed;    
  } 

} else {

  // Apply gravity to our velocity to diminish it over time 
  velocity.y += Physics.gravity.y * Time.deltaTime; </p>
  // Adjust additional movement while in-air 
  movement.x *= inAirMultiplier; 

// movement.z *= inAirMultiplier; }

movement += velocity;

movement += Physics.gravity;
movement *= Time.deltaTime;

// Actually move the character

character.Move(movement);

if ( character.isGrounded ) // Remove any persistent velocity after landing

  velocity = Vector3.zero; 

}

Have you tried just moving along a vector pointing in a diagonal direction? That would seem to be the simplest way to do it.