Giving the player a weapon

Hello All;



I am wondering if there is a way to give a player weapons armor and other items and add it to the visual of the character with out changing models or creating new animations. I am a programmer on a project and not the modeler, I don’t know thing one about blender or xml or any of that, I read and write code. I understand the fundamentals of game programming but java isn’t my native language c++ is. My project lead wants me to attach weapons and armor to the player threw code so we don’t have to make a whole new player model for each weapon and armor set and all variations in between. Most engines I have worked with UDK, Octane, even Game Maker have the ability to add items threw code and not threw new model animations. My question is how would I do this in JME3 (with all the latest updates).



What I have tried:



I have tried adding the weapon as a child to the hand bone

bone.attachchild(weapon) // I know this isn’t really how it would look just giving an example.



I have tried adding the weapon to the hand of the player in the scene explorer I linked the weapon to the player in the window and moved it next to the hand but not quite touching it.



What I am looking for in an answer:



The answer I am hoping for is a code sample or pseudo-code showing me what to do.



I am new to JME and I have gone threw all the tutorials even though they don’t really work anymore. This project is on a deadline and we really can’t afford to redo the character model for every combination as the game will allow hundreds of custom combinations built in the game. The game will be like runescape and mine craft in the crafting system I am sure I will be back later to ask for help with that as well when the time comes.

The way I have been doing it in my game is by getting the attachment node from the model’s skeleton control. This works well for weapons models.

2 Likes
@damionmccoy said:
I have gone threw all the tutorials even though they don't really work anymore.

What do you mean by this? I completed all of the tutorials about a week ago, and all of them worked fine.

Wow I have to say this here is why I hate forms ask a question get everything but an answer.



To the first answer thank you It did work though you explanation means little to me since I am new to the engine. I found an unrelated question on a different website with the answer. But yes it’s the same idea you have given me.



To the second reply really that’s your response? Yes I couldn’t get the tutorials working because the assets for many of them arnt included.



I have built a 3d graphics engine and a 3d multi-threaded engine. I have a degree in game programming. My issue is learning java while learning a new engine. Anyone who has ever worked for a real game company knows sometimes your forced to play catch up with new tech. So before everyone starts treating me like the avrage 10 year old wannabe can we just get to the nuts and bolts.

Go to the google search thing in the bar to the right of the forums.



Type “attachment node”



Press search.



Read things like:

http://www.hub.jmonkeyengine.org/wiki/doku.php/jme3:advanced:animation

http://hub.jmonkeyengine.org/groups/physics/forum/topic/problem-with-bone-attachments/



Try searching for “model equipment”



Read things like:

http://hub.jmonkeyengine.org/groups/general-2/forum/topic/skeletal-animation-system-and-equipment-change/

http://hub.jmonkeyengine.org/groups/documentation-jme3/forum/topic/character-and-equipment-animation-for-many-nodes-using-only-1-skeleton/?topic_page=1&num=15

http://hub.jmonkeyengine.org/groups/general/forum/topic/adding-clothes-to-a-already-loaded-3d-character-that-got-animation/





Now read http://www.mikeash.com/getting_answers.html and think about how maybe you might want to reword your last post…because it certainly didn’t inspire me to want to help you…especially considering its only 14 hours after you posted the first one and at least half the potential respondents haven’t even read it yet…



I realise you might be under a time pressure but if you want people to help you then that’s not the right way to encourage them to do so.






  1. Given keywords you didn’t understand (but actually have the solution to your problem) - try searching for them… or for other relevant terms
  2. You reported a potential problem, someone querying what the problem is may not be helping solve your initial problem but it is very relevant to the future of the engine considering a problem with the tutorials is one that should be fixed. It’s funny that you say the assets aren’t included as the only one I found that wasn’t included is town.zip - and I was told where to download that from. Did you download the SDK and tell it to create the test projects?



    File->New Project->JME3 Tests
2 Likes

You don’t even need to search, the manual (press F1) explains in detail how you set up a project with the tests and all data? It also contains all the “nuts and bolts” and the hints at the very handy javadoc that might be new to you as a C++ programmer.

1 Like

Aside: every time I read this forum title I think of the children’s book “If you give a mouse a cookie…” http://en.wikipedia.org/wiki/If_You_Give_a_Mouse_a_Cookie



I think the book about “giving a player a weapon” would be funny. Could be a nice structure for a tutorial or something “If you give a player a weapon, then he will want something to kill. If you give him something to kill then he will want it to fight back…” and so on.

1 Like

Normen



Thank you that is a good answer and insightful, perhaps you can tell me which area in the manual I can find that in as I have looked there, and didn’t see it.



Zarch:



Thank you this is very helpful as well sometimes its easier to get an answer when you know the proper terminology, something my school skipped over a lot of the time.



pspeed:



Did you start out knowing everything? That must be really nice! some of us have to work from the ground up and ask questions and sometimes they’re things that seem really simple in retrospect. As a developer I would expect that you would understand everyone has a learning curve and be considerate of the fact that many people here are not professionals. I am but this is my first professional project and my first time using jMonkey. If this question is getting asked all the time maybe someone should put the answer in the FAQ’s then you don’t have to insult peoples intelligence anymore.



People a form like this is the only answer many people have, but many people will not ask questions because they are afraid everyone will treat them like they are stupid. And when people to treat them like they are stupid they give up, is that what you want to chase people out of the industry if so producing a free game engine may not be the best choice.



We all know that if you want into the industry you have to have knowledge and experience in the industry, if everyone treated everyone like they didn’t belong because they don’t already know something then no one would learn anything. I commend those on here that at least tried to give an answer, and shame on you who found it an opportunity to make your selves feel superior. I have posted twice on these forums and I already think people here are mostly Jerks who would rather insult people then help them, what an amazing image you put out. Has anyone tried to do a search for tutorials not put out by this website? Good luck on that and let me know if you find some, now look for a mainstream engine like UDK or cocos2d its amazing the resources you find. I searched this site for a week before asking my question, and when I did everyone assumed I was some script kiddie because I didn’t figure it out on my own. I have a game that must be done in 6 months, my team is depending on me to do my job. If we weren’t so far along already I would have built my own engine in c++ instead I suggested this engine I regret that every day. Not because the engine is bad but because there is no help for a first time user besides just do the tutorials.



JME is not a name few people know yet its one of the best engines available to the task, why is that I ask?

Holy crap, dude, chill.



My link had nothing to do with the merit of your question. Just the phrase in the title made me think of the book which is very popular with my kids… since the thread seemed to be winding up, I thought it was kind of funny.



Sensitive much?

1 Like

As I know understand how to attach a weapon thank you for that can anyone point me in a good direction to figure out how to attach a collision box like the capsule for the player to the weapon its self.



[java]

//Add Weapon

SkeletonControl skeletonControl = player.getControl(SkeletonControl.class);



IronSword = (Node) assetManager.loadModel("Models/weapons/iron_longsword/Iron Longsword.j3o");

IronSword.move(0, 1.5f, 0);

Node weapon = skeletonControl.getAttachmentsNode("rightwrist");

weapong.attachChild(IronSword);

bulletAppState.getPhysicsSpace().add(weapon);// this is when I do this the camera moves with the object and their is still no bounding box to use to check collisions

[/java]



I may have missed an example of this if someone know were to start looking again I would be very appreciative. I may also just be doing something like missing an = sign something that often plaques me.

Yea I can be sensitive however I can be really on guard when people are unhelpful. I am under a lot of stress and I apologize if that is coming out here. I just saw in many of the other posts like mine people ridiculing the asker or not being helpful and it was my intent to try and keep this topic on topic.



Again I am sorry.

1 Like

[java]weapong.attachChild(IronSword);[/java]



weapong - > weapon?

1 Like

lol oops see sometimes its something little but I actually retyped the code that’s not what was really there however I did look and thank for the quick response and catch.



EDIT: Legally I cannot show any code I have written on this project the NDA I signed forbids it. So I am showing syntax and structure of of the code if that makes since.

@damionmccoy said:
Yes I couldn't get the tutorials working because the assets for many of them arnt included.


The 2nd sentence in Tutorial 3 : Hello Assets (green background, under the image) often helps people struggling with missing assets... did this help you or is your asset loading issue more severe ?
1 Like

lol ok now I feel really stupid lol I can’t believe I missed that :frowning: this one was all me I’m afraid however thank you for that it will help a lot in my future working threw the tutorials. But on a positive note I did get threw them once I just used some free stuff I found online.

@damionmccoy said:
Thank you that is a good answer and insightful, perhaps you can tell me which area in the manual I can find that in as I have looked there, and didn't see it.

"About jMonkeyPlatform"
1 Like

Thank you!


@normen said:
"About jMonkeyPlatform"

*through

@damionmccoy said:
lol oops see sometimes its something little but I actually retyped the code that's not what was really there however I did look and thank for the quick response and catch.

EDIT: Legally I cannot show any code I have written on this project the NDA I signed forbids it. So I am showing syntax and structure of of the code if that makes since.


The NDA will say you can't show code without permission. I recommend you at least try and get permission (will need to be written) to show selected code fragments on appropriate forums for support purposes. It depends on your manager and how bureaucratic the company is but it is worth asking the question as it can save a lot of time on getting questions answered.


Some people on these forums have more patience than others and there are a few cases where certain people get a bit carried away. Generally in my experience most people are helpful and friendly though... I've already explained why your post didn't help your cause and I'm not sure you listened.

The very first reply gave you the exact keywords you needed to go find the solution "attachment nodes". The second followed up on a potential problem you were reporting. Those are actually both good responses - even if they may not have gone into quite the detail you were hoping for.

Your response wasn't "thanks but I was hoping for more detail", or even "I don't know what an attachment node is, where do you recommend I go to find out more" ... it was a complaint about hating forums and basically saying that the first two people who tried to help you were wasting your time. You then followed up an off topic but not hostile post with an attack on the poster (who incidentally is one of the more helpful people on these forums) and another rant.

Not exactly going to encourage others to help, is it? ;)


However your apology was a good idea and its nice to know the tutorials aren't broken either :)

Hopefully you have the info you need now. Don't be scared to post if you have more questions...most of us have fairly thick skins - just limited time to spare...
@Sploreg said:
*through

It's not just me that's been bugging then? :) I had to stop myself from mentioning it three times as it might seem provocative :evil: