Search Unity

Fake Wind Zones (Partially Done - Need Help Polishing)

Discussion in 'Scripting' started by C10110, Aug 29, 2014.

  1. C10110

    C10110

    Joined:
    Jan 19, 2013
    Posts:
    58
    Hello Unity Forums!

    I was wondering if you guys could help me with a little thing I'm working on. Well, a little thing that's part of a larger thing :p

    I am making a phone game, in where you throw a boomerang in a isometric viewed level, and try to collect and object without hitting anything in the game world. I had the idea to create windzones when I saw a cheap wind Turbine asset on the asset store, and thought it would be a cool thing to add to the puzzle element of the game.

    As it's set up now, I have a sphere collider on my turbine that triggers to throw the boomerang in a direction specified in the inspector, and fail the scene, restet it, etc. Just like if it were to have hit an obstacle, but as I said, it gets thrown in the direction the wind is set to be "blowing."

    What I am wanting to do is make it so that when it hits the trigger that, well, triggers...the wind zone throw/fail it goes into the sphere collider a little bit and kind of...I don't know what word to use...has a gravitational pull effect like magnets, so it looks like the boomerang is going into the wind and then being forced out.

    As it's set up now, the very second it hits the sphere collider it gets thrown in the other direction. So, the collider it self is a little redundant, as it's outline is all that matters, when what I'm looking for is the graphical effect of it's insides. Does this make sense?

    Here is some code snippets to understand better. And a screenshot.

    Code (CSharp):
    1. void OnTriggerEnter(Collider other)
    2.     {
    3.         if(other.gameObject.tag == "Wind")
    4.         {
    5.             Wind wind = other.GetComponent<Wind>();
    6.             rigidbody.AddForce(wind.windDirection * wind.windForce, ForceMode.Impulse);
    7.  
    8.             rigidbody.useGravity = true;
    9.             hasCollidedWithObstacle = true;
    10.             hasCollected = false;
    11.  
    12.             Invoke("ResetBoomerang", hitObstacleDelay);
    13.         }
    Code (CSharp):
    1. public class Wind : MonoBehaviour {
    2.  
    3.     public Vector3 windDirection;
    4.     public float windForce;
    I hope this all makes sense. Any help or insight would mean a lot. I have a friend who's been helping me a ton with this but I wanted to give him a break, see how the forums could do for me. Also it's nice to meet new people, fellow devs. Thanks for reading all that if you got this far! Looking forward to hearing what people have to say!