Hellow everyone!
I just started learning this software and encountered a problem. I want to seek professional answers here.
I have defined a cylinder in the software and can use signals to control cylinder extension and retraction. I need to achieve the goal of pushing cylinders into objects. My current train of thought is to add sensors to the end of cylinders, add animal sensors to the container, and finally call the container -grab, which has achieved the effect of pushing objects out, but when cylinders are retraction, objects will be brought back rather than left.
So how to solve this problem, or what other ideas?
To “release” you’ll need to grab the component to some other container. The simulation world also has a container, so grabbing there would cause the component not to be attached to anything, which I guess is what you want.
@TSy Thank you for your answer!
Could you tell me the specific code of this operation and how to call the container of the simulation world?
Thank you very much!
@TSy I’m sorry I can’t find the code you said in the help manual.
Something like:
worldRootNode = getSimulation().World
worldContainer = worldRootNode.getBehavioursByType(VC_CONTAINER)[0]
worldContainer.grab(comp)
I’m not sure, but you might also need to calculate and set the component’s position relative to its new parent node after grab to keep it from teleporting somewhere next to the world origin.
@captain_feature Thank you very much for your reply!
@TSy Thank you very much for your patient reply!
I tried some code, but I still didn’t get the desired results. So I uploaded the project file. May I trouble you to have a look?Your help would be greatly appreciated!
push.vcmx (1.3 MB)
When the cylinder is extending you can check the signal value and grab the part.
When retracting, you can release the part to the world container.
Working example attached.
push_cylinder.vcmx (1.6 MB)
@Este Thank you very much for your answer, which has given me great help, thank you!