(I don’t know what you call it) Okay so I was watching a video on youtube. (Where something was in FNV) and I happen to found this one video (I don’t know how it goes with fallout) and he was able to grab an object and drag/lift it… How do you do that?
Reason why I’m not trying this yet is because I don’t want to spend the day failing at this…or the next week…
EDIT: I think I need to change the name of this to “How to grab objects in BGE”…Too late, but that’s what I need help with.
Not as in power up grabbing, I just need help with the grabbing and dragging one…
I don’t have time to make a mouselooked example, but you’re capable with python, so you can probably figure this out. Holding the WKEY will pickup the object, and releasing drops it (paste this into the Script.py in the blend i posted, and delete the other scripts).
So, you can use a ray sensor looking for objects with a property pickup, and if that is true and you press P for pickup, it sets a property to true; and that is checked by the script and runs the code.
when you press p again it drops object by not running code.
import bge
def moveObject(object_move, object_target, speed, gravity=False):
'''Moves an object at a gradual rate toward target
:param object_move: the object to move
:param object_target: the object to target
:param speed: the speed of movement
:param gravity: to enable effect of gravity on object
'''
if not object_move or not object_target:
return
if not gravity:
object_move.applyForce([0,0,9.81],0)
start = object_move.worldPosition
end = object_target.worldPosition
last = end - start
last += start
object_move.worldPosition += (last - object_move.worldPosition) * speed
target = bge.logic.getCurrentScene().objects['Empty']
pickup = bge.logic.getCurrentScene().objects['Sphere']
if bge.logic.keyboard.events[bge.events.WKEY]:
moveObject(pickup, target, 0.4)