x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

Product Version: UE 4.21
Tags:
more ▼

asked Dec 13 '18 at 03:55 PM in Blueprint Scripting

avatar image

Blutonis
11 1 2

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

Summary :

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.

more ▼

answered Dec 13 '18 at 11:49 PM

avatar image

CraftyWeazel
62 5 7 12

avatar image Blutonis Dec 14 '18 at 09:57 AM

Hello CraftyWeazel thanks a lot for your fast answer! A really interesting idea to do this. In a first step they should only be rigid but phyics simulation should be activated. I’ll try it out and get back later.

avatar image CraftyWeazel Dec 16 '18 at 01:24 PM

Okay, keep me in touch :) It's an interesting project

avatar image Blutonis Jan 28 '19 at 09:29 AM

Hello CraftyWeazel I wanted to ask you if you could give me an blueprint example on how to do the merging step.

"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."

At the moment I create an array of all overlapping actors which should be merged by an event.

Thank you!

avatar image CraftyWeazel Jan 28 '19 at 01:18 PM

Hi! I don't have enough time to make an implementation, sorry, but I can give you some ideas :)

"All overlapping actors" wouldn't work there as it is only retrieving actors and not static mesh components, which are components in the second RigidBody.

When the second RigidBody is connected to the StickTool, try doing the following:

Get the RootComponent of the second RigidBody, get the array of all its Child components, and in a ForEach loop over that array, detect if each component if of type StaticMeshComponent (use a cast).

If that's the case, you can do two things. Ideally, you would detach the StaticMeshComponent from the RootComponent and attach it back the the first RigidBody's root component (keeping all coordinates relatives).

If that's not possible, you would create a new StaticMeshComponent (there's a node for that), set its StaticMesh and its Material the same, attach it to the first RigidBody's RootComponent and then destroy the second RigidBody's StaticMeshComponent.

Note: if you do the second option, either browse the array backward or delete StaticMeshComponents after having browsed the array or you would have some issues.

avatar image Blutonis Jan 28 '19 at 01:37 PM

Thanks a lot for your fast answer !

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question