Answered

picking up items

eetu 3 years ago updated by Peter - Soxware Developer 3 years ago 1

Hi, I'm trying to create a point n click adventure with objects to take and interact with and also interaction with other characters with objects. I would like to have a hint how to create the interactions. The questions are:

  1. How to pick up items - If a glass is on table, should I have a connected but pinned glass object or instantiate a new one in the hand when taking takes place or parent the one on table with the hand?
  2. Putting the object away - I already have an animation where the character puts object in the back pocket (no matter how big the object is) and I wish to use it - should I have the objects parented to an empty back pocket object and turn then visible and parent them to hand when picked or have them parented in the hand and turn them on after picking them or instantiate them when picking up and parenting to hand?
  3. Giving object to another - When giving (or giving like throwing a knife) an object, should I have both characters have the similar object hidden waiting for the exchange or swap the parent of the object to another when interacting? (I assume here the Timeline sync is needed.)

Or do you have some other great idea how to approach my needs?

regs

eetu

UMotion Version:
Unity Version:

Answer

Answer
Answered

Hi,

thank you very much for reaching out.

All methods that you described are feasible, it's probably more a thing you can decide based on your person preferences (and how it fits into the other systems you use in your game). A few things to consider:

  1.  Re-parenting is usually faster than Instantiating/Destroying and also allocates less memory garbage. But as you're doing it at a very slow interval (only when the user clicks something), you won't notice the performance benefits.
  2. If your objects store some internal states/variables, re-parenting might be easier (as all states are kept). If you switch between new instances, you might have to copy those states.
  3. If the offset between the player and the object you want to interact with can be different due to player input, you might need a runtime IK solution to adjust your pre-made animation to reach the target object correctly. UMotion's IK is baked into the animation, so it can't serve you in this situation.
  4. Make sure your animation is not directly referencing a picked up object that you are then removing (either because it is re-parented or because it is destroyed). This makes the animation point to a transform that doesn't exist anymore. You can instead use an empty GameObject as "anchor" transform that always exists. Parent picked-up objects to this anchor. Move the anchor in your animations, instead of the picked-up object.

Please let me know if there is anything else you want to know.

Best regards,
Peter

Answer
Answered

Hi,

thank you very much for reaching out.

All methods that you described are feasible, it's probably more a thing you can decide based on your person preferences (and how it fits into the other systems you use in your game). A few things to consider:

  1.  Re-parenting is usually faster than Instantiating/Destroying and also allocates less memory garbage. But as you're doing it at a very slow interval (only when the user clicks something), you won't notice the performance benefits.
  2. If your objects store some internal states/variables, re-parenting might be easier (as all states are kept). If you switch between new instances, you might have to copy those states.
  3. If the offset between the player and the object you want to interact with can be different due to player input, you might need a runtime IK solution to adjust your pre-made animation to reach the target object correctly. UMotion's IK is baked into the animation, so it can't serve you in this situation.
  4. Make sure your animation is not directly referencing a picked up object that you are then removing (either because it is re-parented or because it is destroyed). This makes the animation point to a transform that doesn't exist anymore. You can instead use an empty GameObject as "anchor" transform that always exists. Parent picked-up objects to this anchor. Move the anchor in your animations, instead of the picked-up object.

Please let me know if there is anything else you want to know.

Best regards,
Peter