1. first, we animate the actor, in at least 1 action, (so you know it’s ready and won’t be modified much)
2. then we duplicate the actor armature, and go into edit,
3 then select the ik target bone for the aiming arm, and the pelvis,
4. we then do invert selection, crl+I and delete all other bones.
this armature, can accept animations you make on the first armature.
5. than we parent a object to the Arm Ik bone
this is a anchor point in space to move another object,
we will call the objects
Anchor - (where the IK action is played)
IKSwap - A object the player arm IK targets instead of his IK action target)
IkAimTarget = a object rotated via mouse aim.
then we adapt this code for our system.
import bge
def main():
cont = bge.logic.getCurrentController()
own = cont.owner
if 'P1' not in own:
own['P1']=bge.logic.getCurrentScene().objects['IkActionHandle']
own['P2']=bge.logic.getCurrentScene().objects['IKAIMTARGET']
if own['Switch']==True:
if own['Timer']==30:
own.removeParent()
own.setParent(own['P2'],0,1)
own.worldPosition=((own.worldPosition*7)+own['P2'].worldPosition)*.125
if own['Timer']==2:
own.worldPosition=own['P2'].worldPosition
if own['Switch']==False:
if own['Timer']==30:
own.removeParent()
own.setParent(own['P1'],0,1)
##Move Aimer
own.worldPosition=((own.worldPosition*7)+own['P1'].worldPosition)*.125
if own['Timer']==2:
own.worldPosition=own['P1'].worldPosition
#reduce timer
if own['Timer']>=1:
own['Timer']-=1
main()
the IkSwap mus contain theses properties
Timer Integer
Switch Boolean
and runs the following logic.
keypress (swap targets)----------and----------Timer=30
if Timer equal 0------------------/
if Timer Not Equal Zero-------python