Search Unity

Need Help in Level Designing

Discussion in 'General Discussion' started by p4ashant_0236, May 18, 2020.

  1. p4ashant_0236

    p4ashant_0236

    Joined:
    Oct 18, 2018
    Posts:
    4
    Currently i am developing one puzzle type casual game where user have to collect key avoiding obstacles.

    All the levels have different gameplay, different number of enemy, different number of keys etc.

    For example 1st level has 3 enemy that are go from left to right and right to left.
    2nd level has 3 enemy that move in circle to same point.
    3rd level has enemy that has random direction to move.
    etc.

    so i have approximately 120 levels and if i design 1st level it need different script and 2nd need another and so on..
    maybe some level need more than one script for each object.

    so i think you got my problem.
    How can i improve it ?
    can i use 1 script per level that control all the object in scene ? how ?
     
  2. JeySnow

    JeySnow

    Joined:
    Mar 28, 2019
    Posts:
    1
    Hello there :)

    My suggestion is to try and find common behaviours that can be adjusted based on variables, for example:

    Behaviour: Patrol
    Variables: Vector2 limit1, limit2
    Routine: Moves character towars limit1, then change to go to vector2, and vice versa.

    Behaviour: KillOnContact
    Routine: if collided with Player, kill player.


    Behaviour: Die
    Variables: string dieTag
    Routine: if collided with object having dieTag, kill this.

    Then you can mix and match different objects with different behaviours to achieve your unique enemy/chalklenge in a given stage. Also, you can use different scenes for each stage (not the optimal solution, but easy one)

    Hope it helped :)
     
  3. p4ashant_0236

    p4ashant_0236

    Joined:
    Oct 18, 2018
    Posts:
    4
    I also have thought about it.
    But if there is any other way that help me to make it more easy.
    I thought that i can create one script called Level1Controller and it have public variable of all enemy and other thing and all are controlled in same script.
     
  4. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,566
    No, that's inefficient.

    I doubt that in all your 120 levels will have completely unique enemies on each state. There will be repeats.

    There will be multiple times where enemy will display behavior seen before on other levels. Multiple levels will hav nemies that move left to right, or enemies that move in a circle and so on.

    Make a class for that enemy. Make them work independently, without relying on existence of "level script". They don't need a "level script" in the first place.

    Then store enemy configuration as a prefab.One prefab per level, perhaps.

    Then make one "gameplay script" used by all levels.

    Because the only thing "level script" does is counting player lives and displaying gameover screen, and that's the same thing for all levels.
     
  5. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,566
    Basically think about it this way.

    If you're doing a "space invaders" type of the game, here's what's happening.

    1. There's a script that counts score, lives and displays gameover screen.
    2. Player script fires projectiles and explodes when hit by enemy.
    3. Enemies explode when hit by projectiles.
    4. Enemies move in different ways.

    So you need 3 scripts for ALL levels + few more scripts for differet enemy movement types. It doesn't matter how many levels are there, the script will keep doing the same thing.
     
  6. p4ashant_0236

    p4ashant_0236

    Joined:
    Oct 18, 2018
    Posts:
    4
    Thank you for your help,
    i got point.
    Again Thanx
     
  7. p4ashant_0236

    p4ashant_0236

    Joined:
    Oct 18, 2018
    Posts:
    4
    yeah i developed this type of game and i got some point.

    Thank you for your time