![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | GameVisitor |
Hi all,
I want to temporarily remove a node from the physic world (but to be re-introduced later on). Image a big slider, with cubes ( the node ) rolling over it.
I want, upon clicking / tapping a node, to have the node removed from the physical world calculation, go up 10 unit in y axis, until mouse / finger is released, then the node should be back into the physics world.
I would have assumed that set_physics_process( false / true)
should do the job but it is not working for me. Here is a sample code snippet:
func _ready():
# Called when the node is added to the scene for the first time.
# Initialization here
set_physics_process( true )
#pickup
set_process_input( true )
then my pickup logic (called from _input_event()
)
func _on_pickup_cube( curObj ):
#curObj is the rigid object
var parentName = get_parent().name
print(">>>>>Object picked up:" + parentName + " curObj: " + str(curObj) )
curObj.get_node("Mesh-cube").set_surface_material(0, null)
var position = Vector3(0,0,0)
var impulse = Vector3(0,20,0)
#curObj.set_process( false )
curObj.set_physics_process( false )
#curObj.apply_impulse(position, impulse) #ok
#curObj.set_mode( MODE_STATIC )
curObj.set_use_custom_integrator(true)
#print( "after set custom integrator ")
pass
To summarize, the following calls are not crashing but have no effect when turned on (node keeps on rolling)
- set_process()
- set_physics_process()
- set_use_custom_integrator()
where as the below take effect as expected (although not my need):
- apply_impulse()
- set_mode()
- set_surface_material()
Checked this and this but didn’t work for me…
Any idea / tips are welcome
Thx