Answered

Manipulating external objects

thecodehermit 1 year ago updated by Peter - Soxware Developer 1 month ago 4

Hi I am wondering how to go about manipulating external objects from my character. Lets say I have a rigged character and I want him to grab and take an orange and then throw it towards something else. What will be the best way to do that ? For the moment I have been using sort of a cheat, by integrating the objects as part of the character model, though I cant use that for every random object in the future. 

UMotion Version:
1.25p01
Unity Version:
2021.1.4f1

Answer

Answer
Answered

Hi,

thank you very much for your support request.

So first of all, in Unity animation files can only address objects that are a child of the Animation/Animator component. In other words, you can't access objects that are lying around in your scene directly from within your character's animation.

So in every case, this involves  scripting and can't be done purely with pre-made animations. There are simple ways and more complex ways to implement a pick-up system depending on what level of quality you want to achieve. An easy way would be to create a pick-up animation that is rather generic in which the character just picks into the air. Using animation events you can trigger a "pick-up" script in the right moment . This script then checks if there is an object that is "pick-up able" nearby and if so parents it to the players hand.

More sophisticated approaches would use runtime-IK to adjust the pre-made animation to always reach exactly to the object no-matter the current player offset. You could also add different grab-poses per object... As you can see, this can get rather complicated very quickly.


Please let me know in case you have any follow-up questions.


Best regards,

Peter

GOOD, I'M SATISFIED

Ah I see, I hopped that there was a quick and easy way already integrated into umotion. I guess I can go with the generic animation approach and trigger a object animation when a character reaches for something. Though I guess it will be a bit hard to animate when you animate the object, but cant see the character position in time. Anyway I will figure something out, thanks for the help.

Satisfaction mark by thecodehermit 1 year ago
Answer
Answered

Hi,

thank you very much for your support request.

So first of all, in Unity animation files can only address objects that are a child of the Animation/Animator component. In other words, you can't access objects that are lying around in your scene directly from within your character's animation.

So in every case, this involves  scripting and can't be done purely with pre-made animations. There are simple ways and more complex ways to implement a pick-up system depending on what level of quality you want to achieve. An easy way would be to create a pick-up animation that is rather generic in which the character just picks into the air. Using animation events you can trigger a "pick-up" script in the right moment . This script then checks if there is an object that is "pick-up able" nearby and if so parents it to the players hand.

More sophisticated approaches would use runtime-IK to adjust the pre-made animation to always reach exactly to the object no-matter the current player offset. You could also add different grab-poses per object... As you can see, this can get rather complicated very quickly.


Please let me know in case you have any follow-up questions.


Best regards,

Peter

The support here sucks. They can't even understand what difficulty the person is facing. He wants to visualize both the object and the character at the same time so that the animations line up. I'm having the same problem too but I'll figure it out without this useless help.

The support here is usually quite good, but the problem is they haven't implemented that feature...
As for the solution, I was thinking having one extra bone in the character rig. Then putting objects I want to manipulate as child objects of that bone via script. 

I havent had time to test this but I think its going to work. I would appreciate though if you or anyone else shares a better solution.

@thecodehermit: The method you described is the way to go. Combined with animation events, you can trigger your script in the right moment, scan for a nearby object and if there is an object in range, pick it up by parenting the object to the character.


This can't be done with an animation / UMotion alone. It requires scripting to implement this kind of logic.