|
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.
(comments are locked)
|
|
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? I understand what you are saying and the logic behind it, but I don't how to do it in code. The way you explained it is how I want to program it, but the code part is the part I can't figure out...
Oct 28 '10 at 07:50 PM
SirVictory
Right now, inWind is just a flag. I posted the code attached to the find zone.
Oct 30 '10 at 06:32 AM
SirVictory
Edited my post again
Oct 31 '10 at 05:54 PM
Atnas1010
I had the gravity part working, But now my problem is that the Windzone isn't applying force constantly to the player. I added the code in my post.
Oct 31 '10 at 08:05 PM
SirVictory
Do you set the moveSpeed anywhere? What happens if something leaves the trigger, and it's not the player (look at the code I posted) Have you removed this line: moveDirection = constantForce.force = Vector3.forward * -1.5; since you set the moveDirection from the other script. I assume you've made moveDirection public (otherwise it probably wouldn't compile)
Oct 31 '10 at 10:38 PM
Atnas1010
(comments are locked)
|
|
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 :) But, what about the force part?
Oct 30 '10 at 06:30 AM
SirVictory
Probably a few ways of doing this. If it has to be an actual physics force, You could set a trigger that will parent the player temporarily to an empty GameObject that has a rigidbody and is affected by this force. Remember, if you apply a tiny force every frame it gives acceleration, where applying a larger force for a single frame would yield a steady speed. It depends how realistic you want it. (or your could set rigidbody's Velocity, etc)
Nov 02 '10 at 05:27 AM
TheDemiurge
(comments are locked)
|
|
you could use a rigidbody charcontroller and use .addforce I'm using a character controller and for some reason it interferes with it.
Oct 29 '10 at 01:39 AM
SirVictory
(comments are locked)
|
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:
Could you elaborate on the "Can't walk against the force but you can jump" part?
With example 1, the player has already jumped off the ground, so while he is in the wind traveling across the crayon rift, he won't be able to jump. However, in example 2, since the player is still being affected by gravity and is on the ground, he will be able to jump up naturally, even if being affected by the wind.