if (Physics.Raycast(ray, out hit))
{
//Replace the wall with door
Instantiate(doorPrefab, hit.collider.transform.position, hit.collider.transform.rotation);
Destroy(hit.collider.gameObject);
}
this is the problem : I have two rooms spawning side by side and i want a door between them so i raycast from say room1 to room2 and destroy the wall and place a door there but it ignores the walls of room1 and places door in room2 which i don’t want i want door to be in room1 i thought raycast maybe ignores it’s child so i did this:
private void Awake()
{
Transform[] children = gameObject.GetComponentsInChildren<Transform>();
foreach (var child in children)
{
child.parent = null;
}
}
and it doesn’t work can anybody help