here is my link code, for my game
from bge import logic
from bge import constraints
cont=logic.getCurrentController()
own=cont.owner
# get object list
ray=cont.sensors['Ray']
exit=False
time=cont.sensors['Property']
if ray.positive:
if own['target']=="Empty":
scene=bge.logic.getCurrentScene()
add=scene.addObject('HL',ray.hitObject,1)
if ray.positive and time.positive and own['target']=="Empty":
scene=bge.logic.getCurrentScene()
ob=scene.objects['arm2.L']
if 'weapon' in ray.hitObject:
if own.getDistanceTo(ray.hitObject)>4:
exit=True
if exit==False:
if 'Component' in ray.hitObject:
object_1= ray.hitObject['Component']
else:
object_1 = ray.hitObject
own['T']=object_1
if 'OnIt' in object_1:
object_1['OnIt']=True
rot=scene.objects['Rotaion.001']
rot['Linked']=True
rot['x']=0
rot['y']=0
rot['z']=0
scene.objects['Armature']['State']=3
scene.objects['pelvic'].setParent(scene.objects[object_1['vehic']],0,1)
scene.objects['foot1.L'].setParent(scene.objects[object_1['vehic']],0,1)
scene.objects['foot1.R'].setParent(scene.objects[object_1['vehic']],0,1)
scene.objects['arm2.L'].setParent(scene.objects[object_1['vehic']],0,1)
scene.objects['arm2.R'].setParent(scene.objects[object_1['vehic']],0,1)
rot=scene.objects['Rotaion.000']
rot['Linked']=True
object_2 = ob
# want to use
constraint_type = 12
# get Object1 and Object2 physics IDs
physics_id_1 = object_1.getPhysicsId()
physics_id_2 = object_2.getPhysicsId()
pivotPos_X = 0.0
pivotPos_Y = 0.0
pivotPos_Z = 0.0
if 'weapon' in object_1:
object_1.worldPosition=own.worldPosition
object_1.worldOrientation=own.worldOrientation
object_1.applyMovement((0,object_1['offset'],0),1)
own['Con']=constraints.createConstraint(physics_id_1, physics_id_2,constraint_type,pivotPos_X, pivotPos_Y, pivotPos_Z)
own['target']=object_1
scene.objects['WeaponManager']['target']=object_1
own['targetString']=object_1.name
if 'weapon' in object_1:
scene.objects['Aimtrack']['Weapon']=True
scene.objects['Rotaion.001']['Weapon']=True
own['Con'].setParam(3, -3.14, 3.14)
own['Con'].setParam(4, -3.14, 3.14)
own['Con'].setParam(5, -3.14, 3.14)
(there is also the vehicle controls lock in in this same script )
I would like to set a rigid body joint, that allows the object to be moved to where it was picked up, all the way back to where the ray caster is,
so, how do I use the local Y axis, of the ray caster, as the axis of a 6dof joint?
here is the system as it is now,
<br>
Edit:
(Should I add a empty and constraint the object to the empty after it’s aligned with the gun?)
I would like to use only the one constraint if I can get away with it