Search Unity

Zeroing/Stopping Momentum

Discussion in 'Scripting' started by slippyd, Nov 9, 2006.

  1. slippyd

    slippyd

    Joined:
    Jun 11, 2005
    Posts:
    129
    Is there a good way to zero/stop or otherwise set the momentum on an object? I have a scene where I want a script to set absolute boundaries for player object so that if the object goes outside due to some fluke, it moves the object back into the world. However, whenever I do this the object seems to go flying, so I thought zeroing momentum would fix it. Thanks in advance.
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Why not just put a bunch of invisible box colliders around your level?

    Otherwise you can always use rigidbody.velocity = Vector3.zero;
     
  3. slippyd

    slippyd

    Joined:
    Jun 11, 2005
    Posts:
    129
    Wow, don't know how I missed that. Looks like there are a few handy variables and functions on the Rigidbody class. To make this post not a waste of the project lead's time, here's a feature suggestion: allow us to change some of these properties (velocity, angularVelocity, etc.) from the editor, for testing purposes. I don't have Unity in front of me, so chances are it is in there, you just have to change properties from full to debug or something like that. Thank for the help!