Building Snap
Hello Fellow Developers.
For my game i wish to have a snapping system similar to rust where you place a foundation down then walls can snap to the edges. So far i have made 4 'snapping blocks' on each edge and i am attempting to check whether the wall has collided with the snapping object, and if it has i teleport it to the snapping object's X, Y, and Z. The snapping blocks have a box collider and the wall has a rigidbody with Collision detection of continuous dynamic and the gravity is also turned off.
function OnCollisionEnter (collision : Collision) {
if (collision.gameObject.tag == "SnapBlock")
{
transform.position.x = collision.transform.position.x;
transform.position.y = collision.transform.position.y;
transform.position.z = collision.transform.position.z;
}
}
When run ingame and the wall is collided, the wall teleports to it but then slowly floats away.. i bleieve this is due to the box collider but i dont know. any help is appreciated.
Your answer
Follow this Question
Related Questions
Building System Snapping 0 Answers
2d collision detection not working 1 Answer
how to stop an object from moving after a collision 0 Answers