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:
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.
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.
Assuming you are using the default ThirdPersonController.js, find this line
and add these lines after it
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.
Does this work as it should?
The ThirdPersonController.js script has this handy gem in it:
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 :)
answered Oct 29 '10 at 02:22 PM
you could use a rigidbody charcontroller and use .addforce
answered Oct 28 '10 at 11:08 PM