How to create animations between two different objects?

First, i seriously didn’t wanna post this because it’s really a BIG NOOB QUESTION. I mean, in every game, we use this, like opening a bottle, entering the car, playing football and give the ball to other player, using a sword, etc.

I have been thinking for weeks, and i don’t have a solution yet. A big noob question, but i really like to know some ways to do that.



a) 3 hours is not really a long time for 24 different time zones to see your post

b) you haven’t really explained what you want to do. Be as specific as possible. Show us what you’ve tried, etc.

c) have you done the tutorials?

Ok, let me explain better. Suppose i have a player and a sword. How i combine then together to create a guy with a sword, and how do i animate the attack of the player when the player and sword are separate objects? More examples: opening a bottle, entering the car (create the animation of the player and the door of the car being opened), opening a door, etc

In other words, how do i do animations of the player interacting with another thing? Do i need to do 2 separated animations for the two objects?

Sword and car are very different use cases.

For things like swords/guns/bottles etc - things which will get animated as a part of character movement, it is quite simple. You attach them to specific bones of main character (very often it will be just one bone, possibly ‘virtual one’ created just for sake of supporting such things) and let main character animation handle everything. This means that main character will have number of animations - for example 1h sword attack, 2h sword attack, polearm attack etc, but all 1h swords will be attached to same bone and share same animation for main char.

That was easy part. More complex part is if you want to interact between character and some other, independent object. There are few tricks here:

  • for things like shooting arrows etc, it will be variation of first solution - but arrow will just start at proper bone in character and after that fly independent; in case of homing attacks (non-physics based), you will often aim at some specific bone on target (or center of mass)
  • for things like chairs, beds etc, it is even more tricky; you need ‘sit down’ animation on character and put a specific bone/reference point on chair itself; then you perform sit animation, while trying to center ‘ass’ bone on that reference point; complication comes from the fact that you want animation to be started in front of the chair only, so you need to add intermediate zone from which animation can be started (‘front of chair’) and walk there first; often it is implemented in less then perfect way and you will see some magic sliding of character at various stages of animation
  • for things like cars, it is more complex version of chair part - but you will control animations on target object at same time (open door, close door etc); I have never seen it implemented (as I’m meddling almost only with fantasy games), so I cannot give you exact details; in any case, I think that you will have a lot of fun implementing previous cases

Thanks you so much @abies! When you say attaching it to the bone, are you saying I should do that in JMonkey or in Blender for example? And, can you suggest me some videos, documentation or tutorials to explain me how to do that?

Sorry, but im a big noob :wink:

Somewhere in your application code - this is after all, game logic rather than modelling action (weapon was picked up/drawn/whatever).
Regarding tutorials, I would suggest looking how it is done in one of heavily moddable games - in many cases, there is plenty of tutorials for them.

Poking around for a few minutes in the javadoc can also be useful:

You learn to do that and you will be way ahead of so many people.

Thank you @pspeed and @abies for answering this huge noob question!

@Ev1lbl0w said: Thank you @pspeed and @abies for answering this huge noob question!

its not big noob question, newb yes, but not noob :wink:

Ah, ok. I say noob because im a gamer. but thanks anyways :wink: