Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Animated background objects

Discussion in 'Animation' started by FingerInd, Apr 5, 2016.

  1. FingerInd

    FingerInd

    Joined:
    Apr 5, 2016
    Posts:
    38
    Hey dudes, fairly new to using Unity so apologies if this question has already been raised elsewhere but my problem is this:

    I have a bunch of animated background objects - like big fronds - which move slowly in a breeze/current.
    I need collision detection on these elements as I don't want the player to be able to walk straight through them..

    tried searching around for an answer but using mesh collider and/or rigid body doesn't seems to be working

    any ideas?
     
  2. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,521
    A mesh collider should work. Make sure your player also has a collider or character controller, and that the layers of the fronds and player will register collisions. (Check the matrix using Edit > Project Settings > Physics.)

    In the Scene view, if you click on a frond you should see the collider in a green wireframe. You can do the same for the player. Shift-click to select both at the same time. Then try to walk the player into the front. When the colliders meet, you shouldn't be able to walk any further into the frond.

    It's possible that the collider is not following the animation of the mesh. You should be able to see this in the Scene view. If that's the case, try instead adding colliders to one or more of the animated bones of the mesh. This also gives you an opportunity to use a simpler collider, such as a box collider, instead of a mesh collider. Simpler colliders are less work for PhysX and can help improve framerates.
     
    theANMATOR2b likes this.
  3. FingerInd

    FingerInd

    Joined:
    Apr 5, 2016
    Posts:
    38
    Thanks Tony! I will give this a try... does this work with objects animated outside of Unity - such as an animated FBX imported from Max?
     
  4. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,521
    Yes. If you've animated the FBX in Max by manipulating its bones (skeleton, armature, whatever you call them), it carries into Unity just fine.
     
  5. FingerInd

    FingerInd

    Joined:
    Apr 5, 2016
    Posts:
    38
    thanks again!