Place object in specified location

Hi!

I’m started working on a 3D FPS Car mechanic game, and which is the best solution for mount engine parts on the engine block and place object in specified location ? Placeholders without mesh renderer ? or what ?
Thank you, and sorry for my bad english.

Create empty GameObject’s in the mount locations. With these you’re describing the position, and you can even include orientation (rotation), of the thing that gets mounted there.

You can child the parts inside these mounts, or just copy transform location to there, or if you want some weird mount physics you can use a Rigidbody and some constraint to join them.

1 Like

Thank you the fast answer! Okay, and I can pickup object,drop & throw, but must have colliders on the placeholders, no ? For example: OnTriggerEnter { //the object color is green when the right positions,etc… }

?

I’m not sure what you’re describing.

I create empty gameobject in mount locations, that’s okay, but. I pickup the piston and need a collider, that when the part is in right position no ? And If in the piston right position,then object color is change to green and I press left click and place in the empty gameobject location.

This is very specific to your game. So I can’t say for certain.

From what I can tell, you want it so that the mount position has a green silhouette that represents the part that goes there?

If so, no, you don’t need a collider there (unless you also want physics for it, such as to react to OnTriggerEnter/OnCollisionEnter, or whatever). But you will need some sort of meshrenderer and a material/shader to make it green.

1 Like

Yeah,I want green silhouette when the part is in the right position.
Now I’m created the empty GameObject,and I have a piston gameobject. When I press the G Key then Piston1 set parent to Piston1Place,set the Piston1 GameObject position,Kinematic = true,useGravity = false and FreezeAll Rigidbody constraints. This works very good. But when I want place the piston in the cylinder with the mouse,then how ? How do the script know when the piston in right position ? That’s why, must collider or trigger on the empty gameobject no ?

I using Physics.Raycast for the pickup object and drop objects.

If you need physics, then you need colliders.

I need physics,until I put the piston and cylinder, then I don’t need physics. But the problem is, I turn off the piston physics, I don’t know take out the piston from the cylinder, because not detect the click.(because colliders off)