I think i am missing something while working with input() and _inputevent() callbacks.
I want to pickup a RigidBody using touch / mouse left button pressed but only release it when the touch is "unpressed" (even if this event happens NOT on the rigidBody).
I have one script attached to my RigidBody, noting that main scene contains many instance of this rigidbody. (I removed the debugging prints below).
var mCurLiftedBody = null
PickUp: (In order to catch the "pressed" event on this rigidbody)
func _input_event(camera, event, pos, normal, shape):
if (event is InputEventMouseButton and event.is_pressed() == true):
self.set_mode( MODE_STATIC )
#mCurLiftedBody = self
mCurLiftedBody = get_node(".")
Release (Anywhere on the screen)
#if(ev is InputEventScreenTouch && ev.pressed == false):
if(ev is InputEventMouseButton && ev.pressed == false):
if( mCurLiftedBody != null):
mCurLiftedBody.set_mode( MODE_RIGID )
mCurLiftedBody = null
My problem is, not that it is not working, but that it is not Always working...
Sometimes the prints are working correctly (picked up / released) sometimes not.
Sometimes the prints are working correctly but the mesh isn't being nullified ...
I checked this and this too but couldn't find the answer.
The main scene contains other rigid and static bodies and collision occurs but I don't think the problem is from there...