# How to make an object does not "derive"...

Hello, I am making a construction system like in Rust or The Forest. Per example, in those game, when you place a campfire, it’s in green, on the ground and is in front of your player.

So, I tried to do the seem… With Rigibody (i don’t know if it’s the good way). But, the problem with rigibodies are they “derive”, there no longer in front of you and that’s the biggest problem.
How force the rigibodies to always be in front of you at some distance, on the ground (don’t pass trough it) even if the ground is sloping?

PS: Sorry for the misspelling, i don’t speak english very well.

Something like this on the object that is “you” should work:

``````public Transform theObjectYouArePlacing;
public float distance = 5f;
public float distanceFromObjectPivotToBottomOfObject = 1f;

void Update() {
RaycastHit rch;
if ( Physics.Raycast(transform.position, transform.forward, out rch, distance) ) {
theObjectYouArePlacing.position = rch.point;
} else {
theObjectYouArePlacing.position = transform.position + transform.forward * distance;
}
theObjectYouArePlacing.rotation = Quaternion.identity; // reset tilt
theObjectYouArePlacing.forward = -transform.forward; // look at this object
if ( Physics.Raycast(theObjectYouArePlacing.position, Vector3.down, out rch, distanceFromObjectPivotToBottomOfObject) ) {
theObjectYouArePlacing.up = rch.normal; // align to ground
}
}
``````

You might have to change the order of rotations to get the object to face the right way.

Maybe you should get some more practice with making easy things first. Rigidbodies with parents are usually just bad. With more practice, you can see why.

Use more normal child objects, and normal rigidbodies. Or, try putting something on the ground (and it just stays there) – there’s a way to find how high the ground is.