Search Unity

IK require skeleton?

Discussion in 'Animation' started by MikeyJY, Feb 2, 2020.

  1. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    I have an 3D Object representing a tool! This tool is used to mine! I created an animation of this pickaxe, but the pickaxe is going through the stone because it needs to complete the animation! I have no arms to my character only a pickaxe with one "bone". Can I use IK to make the animation to stop at the rock even if the object doesn't have skeleton?
     
  2. Inxentas

    Inxentas

    Joined:
    Jan 15, 2020
    Posts:
    278
    Yes, but it will involve some coding. I am assing a "floating" tool in 1st person view here. I am just a novice so my advice isn't golden, okay? I would use a Raycast to determine the point of impact, and then calculate another point where my pickaxe should be at the end of it's animation cycle. I would then move the pickaxe to that location before the animation plays. All you'd need to know is the proper offset and move the axe towards it. Maybe make it a 2-step procedure.
     
  3. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    Ok thanks, And for chopping trees? Remember I don't have arms only weapons and tools!
    That's my axe animation:
    1st Keyframe:
    upload_2020-2-2_15-1-56.png
    2nd:
    upload_2020-2-2_15-2-16.png
    3rd(same as 2nd):
    upload_2020-2-2_15-2-51.png
    4th(back to 1st):
    upload_2020-2-2_15-3-12.png

    I need to simulate the animation, get the impact point, get the hatchet position at the 4th keyframe? I understood partial your explanation!
     

    Attached Files:

    hippocoder likes this.
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You can use . instead of ! to end your sentences. Because ! in our language is basically shouting or being excited, however the text you're using is quite calm.... :)
     
  5. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    Ok, sorry. May I create another thread on this topic because probably no one will reply anymore here?
     
  6. Inxentas

    Inxentas

    Joined:
    Jan 15, 2020
    Posts:
    278
    Just have patience. That's the primary ingredient for programming succes. If you get such a system working for one tool, I'd just see if I could get it working for other tools as well, abstracting as I go. Chopping trees would be quite similar, so I guess a similar solution would work. Start by making a component that can register these impact points, then just come up with a way for your tool to use that information.

    A simple example would be to make two components: a PointRegisterComponent and a ToolComponent. Have all individual tools extend this ToolComponent, and have the RegisterPointComponent pass off any input to the tool that's currently active. To be honest I wouldn't worry about clipping issues when you are still learning the basics. In general it is better to make the game functional and working before diving into the minutiae of the graphics.

    In my experience working on other stuff gives you a lot of experience that can solve some issue you had earlier. For example, I had trouble making enemy AI and making things way to complex. I later figured out there's a function that lets you pingpong two values, which was enough to get the hit-and-run movement working I had envisioned for some enemy.
     
    MikeyJY likes this.
  7. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    Thank you! Best answer that I received on threads!
     
  8. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    I'm a little bit frustrated because I'm trying to learn IK and FK and I can't figure out these, because there are so many elements: avatar, skeleton, masks, bones, joints and I don't how how to start.
    I just started learning basic animation that has constant proprieties values that can't react to the environment. I asked on forum about how to make animation to stop at objects(tree, rocks, animals) and someone replied me and said I should use IK! I searched on youtube, but I didn't find something for my situation(most of them are for realistic footsteps). I visited the Unity ScriptingAPI IK page! I tried the example for ThirdPersonCharacter from Standard Assets but there are only LeftHand, RightHand, LeftFoot, RightFoot and Head for IK in-built system, and I don't know how to tell the system that the axe is the animator.SetIKPosition(AvatarIKGoal.RightHand,rightHandObj.position), means to move the axe to the impact point!

    PS: Can forum.unity.com send me Windows Notifications trough Brave Browser when someone reply to my threads?
     
  9. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    Visit forum frequently.
    Setup email notifications.
     
  10. Inxentas

    Inxentas

    Joined:
    Jan 15, 2020
    Posts:
    278
    That's because the accumulation of the required knowledge is a long road. You get bogged down if you try to tackle those advanced concepts early on. If you want to LEARN it, I'd recommend you explore the Asset store for characters that support those rigs, download them and pick them apart in a study project, see what makes them tick.

    That's like asking a person that just learned how to draw portraits to copy the Mona Lisa. It would be more relaxing to start with the basics of the Physics engine. Swining an ax in front of the camera and registering if it hit anything is less of a hassle to learn then IK.

    The position at the 4's keyframe is what you could use as a reference point before you start the animation. You'd need to translate that point between local and world coordinates, more your animated GameObject to the offset's location, and start the animation. It's dirty but it would work. Personally I would recommend getting familiar with basic Physics and Raycasting over rigged IK animations. Especially if your character doesn't have arms anyway.
     
    MikeyJY likes this.
  11. MikeyJY

    MikeyJY

    Joined:
    Mar 2, 2018
    Posts:
    530
    You really make an effort to respond to people on forums!