hi everyone
i have had difficulty with this so i was wondering if you can help me
i wanted to create liftable object in blender ge such as the way you can
move objects in penumbra and amnesia
im not all good with python so logic bricks would be better but so far
i can only collide a cube to an empty which disables its rigid body
and tracks it to the empty but this only makes it rotate so i want to
know if anyone can help me
if you want your object to behave as if you pulled from where you clicked it,
that might be quite difficult to achieve, youād most certainly need python for that.
Anyone correct me if Iām wrong, but I believe the only way apply a force to an object
which can result in rotational shifting is to use applyImpulse(), since you can
specify where on your object to apply the impulse to (warning: Iāve never tried it before).
Now youād need quite a sophisticated script to apply the impulse depending on the objects
and your empties position, since you want it to stop after a while (as if you had friction).
However, if you only want your object to copy the position of your empty,
write a small and cute script to parent your object to your empty.
brick: collission with empty-> brick: python script.
python script:
import bge
cont = bge.logic.getCurrentController().owner #gets your hit object
empty = bge.logic.getCurrentScene().objects[āyour_empty_nameā] #gets your empty object
if bge.grabbeditem == None: # if global variable āgrabbeditemā is None, eg you dont hold anything [indenthere]cont.setParent(empty, False, True) #parent your hit object to your empty[indenthere]bge.grabbeditem = cont #and set your āgrabbeditemā to the item youāre holding
*
messes up linebreaks, what the hell?
This script grabs your item on collission, and sets it so you can't grab another item.
However, you'd need another script to release the item again ([removeParent()](http://www.blender.org/documentation/blender_python_api_2_57_release/bge.types.html#bge.types.KX_GameObject.removeParent)) and to set your bge.grabbeditem to None again.
It would make a lot of sense to use a mouse sensor for triggering the script,
so you could simply grab and release again by clicking.
Oh, sorry if I confused you. Savartās code seems like itāll work, but I think the forum software mangled it. This should work:
import bge
cont = bge.logic.getCurrentController().owner #gets your hit object
empty = bge.logic.getCurrentScene().objects['your_empty_name'] #gets your empty object
if bge.grabbeditem == None: # if global variable 'grabbeditem' is None, eg you dont hold anything
cont.setParent(empty, False, True) #parent your hit object to your empty
bge.grabbeditem = cont #and set your 'grabbeditem' to the item you're holding
i was still confused by all this python (i know om dumb xP)
however playing around with bricks ive found a way of doing thisā¦although when picked up the object is stationary
but this is still good it does return to a rigid body when you let go of the left click
thank you all for helping but i think its my lack of phython knowledge thats the problemā¦
ok now ive just decided im not happy with my setup (i know xD)
sooā¦ if i post the blend? could someone please implement this python and then i can see how it was used and hopefully
help my understanding in python (slightly)???
omg im sorry but i cant seem to get your file to work (i even tried it in blender 2.55) it it doesnt seem to be picking anything up
also i use the older version as i find the new version (even more) confusing to use so even if you got it to work i probably wouldnt be able to use it sorry but is it not possible to have it done with blender 2.49?
Wow, this is pretty ridiculous. Yesterday it was working fine, now I get tons of indentation/character errors.
Blender canāt handle the awesomeness that are comments after multilined āif-conditionsā :(.