Weapon in character's palm

Hi everyone! I have a problem when I want to settle a sword in my character palm. I have an animated character. And I have an attack animation (which is connected with right hand bones). I want to add my sword into his hand (and into hip when hero does not attack). How to add different object to specific bone? (so that when I attack, sword will be following after this bone). I was searching answer on forum but I can’t find solution. Thanks in advance.

Attachment nodes

But into bone? I don’t have any method to attach node or model to bone object.

you can do it in the editor

http://hub.jmonkeyengine.org/groups/free-announcements/forum/topic/how-can-haz-attach-a-weapon-to-my-characterzzz/

For your case you can create the attachments nodes for hands and hip, and then just attach the sword to whichever you want at run time.

Ehhh, I’m doing this in Eclipse. Is there a way to do this in this IDE?

I see there are lots of reasons to change Ecplise into JME SDK…

@caro said:
Ehhh, I'm doing this in Eclipse. Is there a way to do this in this IDE?
I see there are lots of reasons to change Ecplise into JME SDK...


Not really... but you could download the SDK and use it just for this sort of thing. I suspect when you edit images or make 3D models that you use an application different than Eclipse. So just think of the SDK like that: another tool for getting a certain job done.

You can do it by code of course too.

On the model you haev a skeletonControl this control has a getAttachementNode(“BoneName”) that returns a node where you can attach spatials.

Ok, I made what you said in Eclipse and my sword is attached to the hip. But how to made this sword “stick” to the bone? Because now it looks like this:

http://www.youtube.com/watch?v=JpYBplK580Y&feature=youtu.be

cant see the video video where I am now but u would be best served to



a) have an actual weapon bone parented to the hand…doing that will offer both flexibilty and increased possibilities for animation your weapons



b) setup your weapon model such that its origin is at the point where u want your character to hold the weapon…reduces the need to introduce messy offsets for the position of the weapons… you may still need to fix the rotational orientation in code though.





also note that “attachment point” for bones in jme is the tail of the bone so position your weapon bone accordingly if u go that route.

Ok, I have my weapon attached to the bone, it follows after hip. But this is not naturally. How to limit weapon movement? Because now it doesn’t look natural. Please look at the video, and you know what I mean.

I want to do this in Eclipse because I have lots of problems with SDK (on Ubuntu is crashing, on Windows doesn’t run).



I have something like this:

[java]SkeletonControl controlSkeleton = hero.getControl(SkeletonControl.class);

Node attack = controlSkeleton.getAttachmentsNode(“hip.L”);

attack.attachChild(sword);

mobile.attachChild(attack);

rootNode.attachChild(mobile);

[/java]

And it works but looks like on the film.

@caro said:
Ok, I have my weapon attached to the bone, it follows after hip. But this is not naturally. How to limit weapon movement? Because now it doesn't look natural. Please look at the video, and you know what I mean.
I want to do this in Eclipse because I have lots of problems with SDK (on Ubuntu is crashing, on Windows doesn't run).

I have something like this:
[java]SkeletonControl controlSkeleton = hero.getControl(SkeletonControl.class);
Node attack = controlSkeleton.getAttachmentsNode("hip.L");
attack.attachChild(sword);
mobile.attachChild(attack);
rootNode.attachChild(mobile);
[/java]
And it works but looks like on the film.


u are better off assigning controller bones like I said above.....animate those bones in your animation app for each movement with the sword attached, in this way the sword will look right based on your animations.............. also u need to pay attention to your model and rig center points


note you are not exporting the character and sword together, you are just using it as a visual que in blender or what ever u use to animate the "holster bone" correctly

all u have to do after that is the initial attach and orient in jme
@caro said:
Ok, I made what you said in Eclipse and my sword is attached to the hip. But how to made this sword "stick" to the bone? Because now it looks like this:
http://www.youtube.com/watch?v=JpYBplK580Y&feature=youtu.be



This is not meant as a knock... because I really like the animated character! But, have you seen Yellow Submarine? The dude looks like he took walking lessons from that movie :)

The solution I came up with this might not be the best, but I never have an issue. Scaling and feature difference aside, all characters are based off of race/sex. All armor/weapons are exported for each of the base choices and I load the appropriate models based on the the race/sex selection of the character. This way, an orc and a human don't have to have the same animation for walking, jumping 1hs attack, picking their asses, whatever, etc, etc, etc.

Ok, thanks both of you. I didn’t see this movie, but I’ll try to watch it :slight_smile:

I’m going to try your solutions and I will write about results :slight_smile: