How can I create a sticky mesh component which then sticks with two other unsticky mesh components? (VR/runtime)
Hi , I’m creating a VR game where the player should be able to freely create his own constructions. I would like to do this with a barely visible, flat sticky mesh component which sticks with two other unsticky mesh components. F.e. if the player wants to create a table it’s important that he can freely chose the position of a table leg upun the tabletop. So his first step would be to stick the sticky mesh component to the exact point on the tabletop where he wants the table leg to be placed. The second step would be that he places the tabel leg onto the sticky component. Does anyone know how to design such a sticky mesh component? Thank you!
asked Dec 13 '18 at 03:55 PM in Blueprint Scripting
It depends on whether you want your meshes to be connected in a elastic and dynamic way, like ragdolls, with physic simulation, or if you want your overall object to be rigid.
Does your project even implements physics?
Either ways, I would think about having this :
1 - objects containing a rigid assembly of static meshes (as components) --> Let's call it "RigidBody"
2 - your sticky magical object --> Let's call it "StickTool"
Your StickTool would have two RigidBody references - empty at spawn - and wouldn't simulate physics at all. Whenever you place it on the first RigidBody, you put it in its first reference holder. Also, in the Tick event, you make sure that the relative transform of the StickTool to the RigidBody remains the same.
Then, when a second Rigidbody is brought in contact with the StickTool, you detect it and place it in the second reference holder. Then "connect it" (just teleporting in a few centimeters to match the faces properly).
Then, for the magic to happen, without waiting the next tick, you'll have to merge the RigidBody's together. For each staticMeshComponent of the second reference, you create a new and equivalent staticMeshComponent in the first reference. Then, you delete the second reference and the StickTool, so that what's left is an assembled RigidBody with new parts.
RigidBody, an actor with some StaticMeshComponents. It simulates physics and collisions.
In its variables are an Array of StaticMeshComponents, in order to easily manipulate them.
It has a function that adds a new StaticMeshComponent to the array and place it at a specific relative transform, based on the relative transform of another RigidBody and the relative transform of the new meshComponent inside the other RigidBody.
You will have to develop great Transform functions, in order to manage the maths of everything.
StickTool, an actor with a StaticMeshComponent of small size. It doesn't simulate physics, but generates overlap events.
It has two variables : a reference to a first RigidBody, and a second RigidBody.
It can connect to a first RigidBody by storing its reference and by this time it will keep the same relative transform to this RigidBody.
Then a second RigidBody can be connected to it, stored in the second reference. As soon as it is done, it's triggering the merging function of the first RigidBody which will copy every StaticMeshComponents of the second RigidBody into the first. Then, it destroys itself and the second RigidBody.
answered Dec 13 '18 at 11:49 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here