Question How to make multiple objects connect and act like one solid object?

Discussion in 'Physics' started by Drewen_Schoon, Feb 8, 2023.

1. Drewen_Schoon

Joined:
Mar 4, 2019
Posts:
10
I want to have two objects (or more) lock together and act as one object. I am making a car-building game where you can build the car with small blocks. Inspired by games like scrap mechanic, besiege, terra tech, and trail makers. You place two 1x1x1 blocks parallel and weld them together and I want it to act like a 2x1x1 block.
You usually use fixed joints and it works really well but in my game, I will have a high amount of connected blocks so it is laggy and enough weight will make the joints bend and glitch out even with higher physics updates. so I can make the block connect through code and rotate together and act like 1 solid object?
how do the other games achieve the building part with such little lag even with thousands of blocks?

I already have the building script done and right now I'm using fixed joints (on every block connected to the parallel block) to hold stuff together until I find a better solution.

2. arkano22

Joined:
Sep 20, 2012
Posts:
1,841
Unless you need them to break and fall apart at runtime when under enough stress (or want each block to have different mass/drag/etc) there should be no need to use joints for this.

How about just put multiple objects (each with its own collider) under a rigidbody's hierarchy? they will behave as a single body. This is usually referred to as a "compound collider" setup.

3. Drewen_Schoon

Joined:
Mar 4, 2019
Posts:
10
Thank you, I do like this idea a lot and I did not think of that. But I would like some of the blocks the weigh more and eventually have aerodynamics. So it would be nice to have separate rb just so I can use the mass variable. I can probably code the aerodynamics my self without rb drag, so that is not too bad. But some people playing the game may want to use heavy blocks to make the car weigh differently on specific parts of the car.

I may just make a light weight hierarchy connect to a heavy hierarchy of blocks (with joint) and that would limit joints a lot compared to my old method if you have other ideas please tell me. But thank you again

Last edited: Feb 8, 2023
4. Tutoroot

Joined:
Feb 1, 2023
Posts:
7
Thank you, I do like the information that you have provided information about solid objects. If you have any other topics related to this please share them.