Different relative spawning positions

So, if you have a character with multiple weapons, how would you make the character spawn a gun on another layer when the gun positions are all different?

So for example…you have a pistol, when you spawn in a shotgun, the position of the shotgun is going to be different from you pistol when you change.

You can have the guns in the scene somewhere the player can’t see them and move them back and forth, or you could have them all by the player but transparent and change the transparency based on which one is equipped. Look in Blender’s API for ways to set objects position or transparency if your’e using Python, or look through all the logic bricks for actuators that can do the same thing. Is that what you wanted?

I’ve thought about that, but the game is multiplayer, so I can’t have it where the player can’t see it because other players will see it and it will look strange. If I used your other method, then couldn’t be able to change the physics, so if the player gets caught(stuck) on something, and the gun is invisible then the player will get frustrated…hmmm…sorry I forgot to tell you about multiplayer :confused:
Plus, the game will start out with 10+ different guns. Is there a way for python to spawn an object at a specific location relative to something?

Why can’t you just move it where ALL of the players can’t see it, like underground maybe? Also, what do you mean by relative to something? You can just have an empty that you move around and make it spawn the weapons :slight_smile:

How FPS games work is there are world models, equipped models and view models.

World models are for weapons that lay on the ground and these are pretty lowpoly. They have physics colliders and pretty much don’t do anything. Low detail. Make them appear and disappear in BGE with addObject() and endObject() when they are dropped, picked up, start/end of a round, etc.

Equipped models are for when you see other people equipping weapons. They are parented to a bone (or in BGE empty that is parented to the bone) of the player character model. No collision, low detail, often you use the same models as world models. Make them initially appear and ultimately disappear in BGE with addObject() and endObject() and then toggle visibility according to what the player has equipped.

View models are the models player can see on his screen. These are cosmetic elements only, to tell the player what he is doing. They are high-poly weapons that are on separate render layer so they don’t interact with the world in any way except sometimes share lighting. In BGE you should make this with overlay scene. Hands are part of the weapon view model and in examples such as CS:source you can find them separately for each weapon view model. Make them appear and disappear with addObject() and endObject() as player gets the weapon or loses it. For which weapon he has equipped you should probably move them away from sight, say downwards by enough of units with a weapon animation (unequip) and turn it invisible just to be sure. Logic is still processed for invisible objects so you need a property for controlling which weapon is active. This sets all the other weapons invisible and moves them out of sight as well as disables any logic being run for that weapon so it doesn’t play the animations etc because it still uses resources even if it isn’t rendered.

I 100% agree with Kheetor.

A) There are no (logical) layers. There are just active and inactive objects. So I translate this into:
“How to exchange a gun model by ending and adding objects”

B) Why are these “gun positions” different?
If you make them all the same you would not have this problem.
If you think about different hand positions for different things to be used it is still the same. Have the same reference point relative to one bone. Parent the object and let the armature play the according pose.

remove whatever the hands currently hold
play the crossbow holding pose (arm/hands armature)
add and parent the crossbow to the relevant bone

remove whatever the hands currently hold
play the stone holding pose (arm/hands armature)
add and parent the stone to the relevant bone


remove whatever the hands currently hold
play the barrel holding pose (arm/hands armature)
add and parent the barrel to the relevant bone

all you have to care is the relative position to the relevant bone (origin of the object relative to the right hand bone)

I didn’t realize that this was such an ambitious project, I was imagining a top down shooter sort of thing with simple graphics where you wouldn’t need a system like Kheetor described. Kheetor’s description is the typical method I’ve heard of for FPS’s and it’s pretty solid.