- Home /
Question by
B3nji_ · Nov 16, 2018 at 10:19 PM ·
c#scripting problem
Detect Near objects
i want to make a randomly generated map but with some rules i did (for ex. if a corner road is below the game object, itself will be a strait road). the problem? i have 60 different combinations (with 12 types of road detected in 5 places) and i don't think that's the only way to approach it.
An example of the script:
Void Start()
{
if (RoadBelow.GetComponent<SpriteRenderer>() == CornerRoad)
{
gameObject.GetComponent<SpriteRenderer>().sprite = StraitRoad.sprite ;
}
...
}
Comment
Some multi-pass algorithm required, and I suggest you to work on data layer before actually creating gameobjects. Then when something changes, for every tile there may be some interface to check if it should change according to rule set. These rule set is the most complex thing to do. Try to google for that matter, I'm sure many developers have done something similar.