Wind Forcing on a CharacterController Object

alt text I'm trying to figure out how to make "wind" force a character to a direction. I mainly want it so that if the player jumps over a canyon, the wind will guide him to the other side. I set something like this by doing this:

I set a trigger box and made it so that when the player collides with the box, it make the variable "inWind" to true in the player's ThirdPersonController script and this is the code I added to the ThirdPersonController's ApplyGravity function:

if (inWind)
    {
    moveDirection = constantForce.force = Vector3.forward * -1.5;
    //constantForce.relativeForce = Vector3.up * -1.5;
        //moveDirection = Vector3.forward * -1.5;
    verticalSpeed = 0.0;
    gravity = 0;
    }

However, the player is able to "move" against the wind. I don't want to make the player unable to move at all, because I still want the player to still be able to glide themselves. Any suggestions?

Here is the code attached to the windzone.

function OnTriggerEnter (hit : Collider) 
{
 if (hit.transform.tag == "Player") 
   { 
    var controller : ThirdPersonController = hit.GetComponent(ThirdPersonController);
    Debug.Log("enter");
    hit.gameObject.GetComponent(ThirdPersonController).inWind = true; 
    //controller.isTalking = true;
    //controller.animation.Play("swim");
    }
}

function OnTriggerExit (hit : Collider) 
{ 
    var controller : ThirdPersonController= hit.GetComponent(ThirdPersonController); 
    if (controller.IsGrounded !=null) 
    hit.gameObject.GetComponent(ThirdPersonController).inWind = false; 
    //controller.animation.Stop("swim"); 
    controller.gravity = controller.defaultGravity; //20.0
    //controller.isTalking = false;
    Debug.Log("Left the water"); 
} 

UPDATE Here is the current windzone code. The windDirection variable shows up in the inspector and I am using the X and Z variable as the wind direction.

var windDirection = Vector3.zero;

function OnTriggerEnter (hit : Collider) 
{
 if (hit.transform.tag == "Player") 
   { 
    var controller : ThirdPersonController = hit.GetComponent(ThirdPersonController);
    Debug.Log("enter");
    hit.gameObject.GetComponent(ThirdPersonController).inWind = true; 
    //controller.isTalking = true;
    //controller.animation.Play("swim");
    }
}

function OnTriggerExit (hit : Collider) 
{ 
    var controller : ThirdPersonController= hit.GetComponent(ThirdPersonController); 
    if (controller.IsGrounded !=null) 
    controller.inWind = false; 
    //controller.animation.Stop("swim"); 
    controller.gravity = controller.defaultGravity; //20.0
    //controller.isTalking = false;
    Debug.Log("Left the water"); 
} 

function Update()
{
     var controller : ThirdPersonController= GetComponent(ThirdPersonController); 

    if (controller.moveDirection != windDirection && controller.inWind)
    {
            controller.moveDirection = windDirection;
    }
}

Assuming you are using the default ThirdPersonController.js, find this line

moveSpeed = Mathf.Lerp(moveSpeed, targetSpeed, curSmooth);

and add these lines after it

if (inWind)
   moveSpeed *= 0.2;

Does that give the desired movement behavior?

Do you have some windzones that need to have one half where you can jump, and another half where you can't? If you don't I've slightly modified the code you posted to make it work as I think you want it to. And remember to remove the part you have added to the Apply section.

function OnTriggerEnter (hit : Collider) 
{
    if (hit.tag == "Player") 
    {
        var controller : ThirdPersonController = hit.GetComponent(ThirdPersonController);
        Debug.Log("enter");
        controller.inWind = true;
        if (gameObject.tag == "WindzoneNoGround")
        {
            controller.verticalSpeed = 0.0;
            controller.gravity = 0;
        }
        //cotroller.isTalking = true;
        //controller.animation.Play("swim");
    }
}

function OnTriggerExit (hit : Collider) 
{
    if (hit.tag == "Player")
    {
        var controller : ThirdPersonController= hit.GetComponent(ThirdPersonController); 
        controller.inWind = false; 
        if (gameObject.tag == "WindzoneNoGround")
            controller.gravity = controller.defaultGravity; //20.0
        //controller.isTalking = false;
        //controller.animation.Stop("swim"); 
        Debug.Log("Left the water"); 
    }
} 

Does this work as it should?

you could use a rigidbody charcontroller and use .addforce

The ThirdPersonController.js script has this handy gem in it:

private var isControllable: boolean;

If you want the player to just wait out the wind, just disable this one. Also check out the CanJump variable in there. One of these two, or some variation thereof, should do the trick :)