Search Unity

sphere collider animation

Discussion in 'Animation' started by 2dgamemania, Mar 23, 2017.

  1. 2dgamemania

    2dgamemania

    Joined:
    Apr 30, 2014
    Posts:
    153
    Hi, I have a cog style object which a player jumps on top of with a character

    The cog has a sphere collider attached which rotates 360 degrees.

    What i want is, if the player jumps on the cog the motion of the character moves with the cog so if the cog turns right the character moves right with it until the player falls off it. At the moment what is happening, is that the character lands on the sphere collider but the player doesnt move with the animation, i have animate physics on which i thought was the option i needed but doesnt work. All that happens is, the character slides of the sphere collider but not with the animation of the cog taken into account

    any ideas?

    Thanks
     
  2. 2dgamemania

    2dgamemania

    Joined:
    Apr 30, 2014
    Posts:
    153
    i attached my character to the cog so it moves with the cog but cause the cog has a rotating animation on it, it applied the rotation to the character, so it kinda works but i dont want it to rotate the character, only to move it.
     
  3. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Is the cog animated with physics, or just a regular keyframe animation?

    Idk if this is a good solution or not, but thought I'd try to help.
    You could put box colliders around the sphere collider, attached to the sphere collider. And then the player character could be parented to the box collider he jumps onto. Since the box collider is not 'rotating' this might overcome the issue of the character inheriting the sphere colliders rotation.

    Another option could be to create a small empty game object at the center of the cog. Parent the empty game object to the cog, then when the character jumps onto the cog parent the character to the empty game object. The character will rotate with the empty game object, but since it is located at the center of the cog, the rotation of the character will match the rotation of the cog animation.

    Alternately consider looking into 2D effectors (surface or platform) or physics materials - although I have little experience with these - so unsure if they would be helpful or not.
     
  4. DavidGeoffroy

    DavidGeoffroy

    Unity Technologies

    Joined:
    Sep 9, 2014
    Posts:
    542
    What version are you using?
    We fixed a longstanding bug recently where velocity was not applied to objects animated by the animator, even with animate physics enabled.
    The fix is in the latest 5.6 betas, if you want to try it out