#Procedural generated gives me back pain

1 messages · Page 1 of 1 (latest)

reef socket
#

basically, I need to spawn in rooms, that can be spawn on the Spawner , while making sure they wont overlaps on each other

#

I have Checker, that need check if the area is occupied or not

#

once all of the checker is finished checking

#

the CheckerParent will decide whether to to enable RoomParent or to destroy RoomTest

#

once RoomParent is activated, SpawneParent will spawn more room on Spawner and then repeat until reached the room cap, or no more room can be spawned

#

Checker script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Checkers : MonoBehaviour
{
    public bool isScanned = false;
    bool isOccupied = false;
    public bool isReady = false;

    void Start()
    {

    }
     void OnCollisionEnter(Collision col)
     {
        if (col.gameObject.tag == "OccupiedSpace" && col.gameObject.tag == "CheckBox")
        {
            isOccupied = true;
            isScanned = true;
            Debug.Log("isOccupied");
        }
        else 
        {
            isOccupied = false;
            isScanned = true;
            Debug.Log("isNotOccupied");
        }

    }

    void Update()
    {
        if (isOccupied == false && isScanned == true)
        {
            isReady = true;
            Debug.Log("isReady");
        }
    }
}
#

CheckersParent Script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Scanner : MonoBehaviour
{
    public List<Checkers> CheckersList;
    public GameObject thisRoom;
    public GameObject RoomParent;
    public GameObject CheckersParent;
    void Start()
    {
       
    }
    void Update()
    {
        foreach (Checkers Checker in CheckersList)
        {
            if (isOccupied == false && isScanned == true)
            {
                Destroy(thisRoom);
            }
            else
            {
                RoomParent.SetActive(true);
                Destroy(CheckersParent);
            }
        }
    }
}
#

SpawnerParent script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class RoomSpawning : MonoBehaviour
{
    public List<Transform> Spawners;
    public List<GameObject> Rooms;
    public GameObject Scanner;
    private int SpawnerNum = 0;
    void OnEnable()
    {
        GameObject manager = GameObject.Find("RoomsManager");
        RoomsManager managerProperty = manager.GetComponent<RoomsManager>();

        //GameObject area = Scanner;
        //Scanner areaProperty = area.GetComponent<Scanner>();

        while (managerProperty.maxRoom > managerProperty.RoomCount && SpawnerNum < Spawners.Count )
        {
            SpawnerNum++;
            Instantiate(Rooms[Random.Range(0, Rooms.Count - 1)], Spawners[SpawnerNum].position, Spawners[SpawnerNum].rotation);
        }
    }

    // Update is called once per frame
    void Update()
    {
        
    }
}
wraith cloud
#

add cs to your code blocks

#

I probably can't help much with the issue though

#

And even if I can, definitely not now because I lack sleep

wraith cloud
reef socket
#

srr

wraith cloud
#
your code here, add cs on top so that it colors syntax
reef socket
#

The problem is that the the checker script doesnt seem to work

#

it called on collision, so I added CheckBox basically a box collider overlapping the checker collider to activate it

fierce belfry
#

What's happening vs what isn't?

reef socket
#

hang on

#

the checker script will start the chain, when I press play, there is nothing in log

#

OnCollisionEnter wasn't called

#

despite the 2 collider was overlapping

wraith cloud
reef socket
#

nope

wraith cloud
#

¯_(ツ)_/¯

trail vigil
#

one of them must have a rigid body for a collision to occur

reef socket
#

what if I change it to OnTriggerEnter?

trail vigil
#

Nah, one of them still has to have a rigid body from what I recall it's a bit annoying

#

you can make the rigid body kinematic, so that it isn't effected by forces and make it's collider a trigger so it doesn't run into anything, but yeah 😐

reef socket
#

hmmm

#

do you have any suggestion?

#

on how I should do this

#

except for grid

trail vigil
#

I think you can use physics.checkbox instead of an actual collider with a rigidbody?

#

A grid isn't a bad idea, unless the rooms are not precisely sized, if not, just create bounding boxes for each "room" and make sure those are not intersecting

reef socket