I have a Basic arms setup in a first person view and an empty parented to the hand bone. I know that this empty tracks flawlessly because i can parent a cube to it and see that everything follows. I have 3 guns that the player can switch to. whenever the player switches an animation plays out. However if the player moves their view it seems to apply a constant offset to the weapon. I im at a loss as to what im supposed to do.
Parent the mesh to the hand bone rather than the empty, then swap it out when switching weapons. That’s how I do this kind of thing anyway. I can’t tell what’s causing the offset from just a picture but I’d guess the gun is transforming in world coordinates rather than local.
How would i change it to local? is it in the add object function or the parent function?
This seem similar to my problem.
I used 2 emptys And still if i wiggle the armiture about (the view of the player) the gun gains an ofset.
So let’s see if I get it. You use the empty to spawn the gun, parent the gun to the empty, then play an action on the gun? If so, then I bet your keyframes are overriding the guns location/rotation.
Im not sure how i would fix that. If i hold completely still it works as intended though. its just when the armature moves fast. almost as if the gun empty cant keep up. is there a way to fix the keyframes if thats the case?
I’d suggest adding a bone to the armature, and applying animations intended for the gun to it.
ok, you’ve missed me there. The animations for the gun? I don’t see how i could even begin. Ill make a striped down scene for you to look at because you seem to be light-years ahead of me.
Alright, here’s the problem – you’re parenting with logic bricks and that doesn’t take effect until the next frame. So it looks something like this –
gun is added at the position of empty > empty moves around > gun is parented to the empty, while at it’s old position. So that’s our offset.
The fix? Parent the gun to the empty on the same frame it is added to the scene.
#GunChange.py -- line 56 if target == 1 and change == True and timer == 40: wep = scene.addObject("EVO", own, 0) wep.setParent(own) if target == 2 and change == True and timer == 32: wep = scene.addObject("pistolEmpty", own, 0) wep.setParent(own) if target == 3 and change == True and timer == 40: wep = scene.addObject("Scout", own, 0) wep.setParent(own)
I thought of parenting through python but never in this sense. Thanks!
tro add to @Liebranca post:
wep.localPosition = [0,0,0]
Also helps, in some cases the weapon will be not right positioned after a spawn, this ensures that the weapon goes back into it’s original position. so an additional placement to stick to the empty it gets spawned on.