Search Unity

Access parents rigidbody.velocity to trigger Animation!!

Discussion in 'Animation' started by stahlbrand1997, Apr 21, 2021.

  1. stahlbrand1997

    stahlbrand1997

    Joined:
    Nov 20, 2018
    Posts:
    11
    Hi!

    It honestly feels simple but I cant wrap my head around how to do this :/

    I have an empty game object which has a capsule collider and a rigid body. This empty game object is the parent. I have the actual model of my character as a child, to my understanding I have to add the animator and animation script to the model, not the parent.

    How do I access the rigidbody.velocity.y or detect collisions through a script when the script is attached to the child of the parent that has this rigidbody and capsule collider???

    Please help :))
     
    mattmag likes this.
  2. launzone

    launzone

    Joined:
    Dec 2, 2015
    Posts:
    57
    The animator does not need to be on the game-object that has the model itself. As far as I know the animator can only access properties that are lower or the same in the hierarchy (only itself and children, not parents or other non related game-objects).
     
  3. stahlbrand1997

    stahlbrand1997

    Joined:
    Nov 20, 2018
    Posts:
    11
    This! Thank you for explaining this, been so confusing haha. How would you go about activating the animation through the parent instead of the model is a child?
     
    mattmag likes this.
  4. launzone

    launzone

    Joined:
    Dec 2, 2015
    Posts:
    57
    i don't exactly understand what you mean.
    not sure if it helps in your case but i think you can have multiple animators. one could be on the parent animating certain parameters, another could be on the child animating other parameters.
    or are you talking about how scripts on different game-objects are talking to components on other game-objects?