|
Well,Is there some sort of an easy way in Unity how to make a zone where from time to time will a strong wind appear and will turn objects with rigidbody down?Like when you walk into a strong water flow.
(comments are locked)
|
|
Yes it is possible. Maybe do a SphereCast in the direction of the flowing water, for any colliders in that cast that have a rigidbody, add force. I like this idea better than an invisible collider and OnTriggerEnter, but those are 2 methods. http://docs.unity3d.com/Documentation/ScriptReference/Physics.SphereCast.html http://docs.unity3d.com/Documentation/ScriptReference/Collider.OnTriggerEnter.html EDIT : I have made a script from the following Unity Script References : http://docs.unity3d.com/Documentation/ScriptReference/Physics.RaycastAll.html http://docs.unity3d.com/Documentation/ScriptReference/Physics.SphereCastAll.html castDirection is a world-space Vector3; meaning if you put (-1,0,0), then the direction is pointing negatively along the X-axis; put (0,1,0) and the direction running positively along the Y-axis(pointing up). Try Different values for x,y and z, just keep them between -1 and 1. I have now included a linedraw-er in the script, you can see what is affected by changing these values. You shouldn't include this in your build, it's just handy for showing where the spherecast is in the editor while designing and building. castRadius, castDistance and amountOfForce should be self-explanatory =] EDIT 2 : this script has been edited to include a time for the flow to be active and then time for the flow to be inactive. Set the flowTime (currently 10seconds on, 10seconds off) : I have a web build of an example to show it works. The above script is on an empty gameObject, just under the white pipe =] wasd or arrows to move green sphere : rigidbodystream webbuild Wow thanks dude, this is exactly what i ment!I never could have done this alone.Thumbs up to this guy =]
Jul 13 '12 at 06:39 AM
DOGY149
By the way.Which number represents the direction?This is a very usefull script which can be used in more things :).
Jul 13 '12 at 10:56 AM
DOGY149
When you SphereCast, the direction is the 3rd number Vector3 AddForce is also given as a Vector3
Jul 13 '12 at 11:30 AM
alucardj
So change the number of the Vector right?In my movement script ive got left and right on Vector3. So i suppose Vector2 is for up and down?
Jul 13 '12 at 04:15 PM
DOGY149
I have re-written my original answer. It is much more detailed, and exposes some variables for you to see what is happening. Also, I am quite proud of the Debug LineCaster to show where the SphereCast is affecting the world, only seen in the editor view. Check out my edited answer =]
Jul 13 '12 at 07:03 PM
alucardj
(comments are locked)
|
|
Everything is possible, you just need to know how :)
(comments are locked)
|

this is a very complex script but maybe look at the windzone effect... (I don't understand it but it's mybe a tip for u)
Thanks for pointing me into the right direction dude.I think i understand it.But there is one problem. My char doesnt have a character controler.Its a simple sphere with some movement,jump scripts.Can i change the var to get component rigidbody?Because how will it recognize my ball?Thx again
I have added an answer with some script that may help =]