Search Unity

Vacum-cleaner!

Discussion in 'Scripting' started by robertseadog, Oct 26, 2005.

  1. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    Im confused here..

    Is there a way to set a force to a certain group of rigidbodies in let's say 3 units radius from my main obj?

    Im creating a vacumcleaner thingy :D
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    The easiest way to do this is by making a trigger collider.

    Inside function OnTriggerStay, you apply a force which pulls towards the center of the trigger.
     
  3. Jonathan Czeck

    Jonathan Czeck

    Joined:
    Mar 17, 2005
    Posts:
    1,713
    Check out Physics.OverlapSphere() and the Explosion.js script in the Script Tutorial project.

    edit: Joachim's way is even better. :)

    HTH,
    -Jon
     
  4. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    ah, neat solution! I'll start playing now!
     
  5. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374
    One more thing: How to I Activate/deActivate a trigger (I only want to vacume one at a time!)?
     
  6. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    gameObject.active=false;
     
  7. robertseadog

    robertseadog

    Joined:
    Jul 23, 2005
    Posts:
    374