Search Unity

2D game development - seeking some answers

Discussion in '2D' started by 12dollar, Jan 31, 2015.

  1. 12dollar

    12dollar

    Joined:
    Jan 3, 2015
    Posts:
    18
    hi guys,

    as I get more and more into Unity (just did some minor 2D games with no artificial intelligence - AI - at all) I have some questions regarding doing some more complex games and hope to get some answers and maybe links / tutorials from you experts ;)

    I.) Is it possible to create an infinite 2D platformer where the level is rendered in a random way? I only did sidescrolling games where the ground starts from the beginning after some time.

    II.) How should I implement artificial intelligence. I did a sprite for a boss monster for example that has 3 different attack moves, a block and a few other jump/run/walk/idle moves. Just randomly doing those moves seems like a stupid idea to me. One animation shows the enemy / player being hit knocking the head back and forth. I know I'm able to play this animation when the player / enemy gets hit. But showing this animation everytime e.g. the enemy gets hit will just looping it if the player presses the "hit button" constantly. Hope I was able to explain it well enough.

    III.) One attack move is supposed to hold the player by his neck and kick him. How am I able to reach the player being hold and not able to move? Just disable his playercontrols during this phase?

    IV.) If the enemy kicks the player the collider of the enemy has to follow the movement. otherwise it wouldn't for example recognize the leg being into the air instead of the ground.


    Thanks so far. Hope I wasn't too noobish asking all of this.

    Best wishes,
    12$
     
    Last edited: Jan 31, 2015
  2. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    1. yes
    http://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/infinite-runner

    2. why not randomly ? :)
    at first boss should go to player (or you can let them just run between some point). If player is in fight range, boss can attack with one random attack of three. If boss is hitted, then stopp atack (walk) and play animation for hit. If player out of range, so stop attack and folow him. So you have priority for AI: dead-hitted-run-attack (ok, forget block. You can make it random as one attack move).

    3. yes
    bool isHolded;
    void Update () {
    if (!isHolded) { here move script) }

    4. i have maked it easy. Enemy just has one trigger befor him (like place, where sword swings), then i check this trigger, if enemy make attack move. Ok, it dont work exactly, but for my game was enough.
     
  3. 12dollar

    12dollar

    Joined:
    Jan 3, 2015
    Posts:
    18
    thanks for the fast response and link.

    regarding II: yeah thought the same about making it random. but that wouldn't be really some artificial intelligence.

    regarding III: about holding the player, seems there is no other way as to stop the playercontrol.
    I still can't imagine how grabbing the player by his neck, hold him into the air and kick him would be performed. there are so many factors to calculate.

    regarding IV: well that sounds a little akward :D

    another question would be how to generate some nice sprite sheets. I have all my enemies and the player in separated png files now. I've read sprite sheets improve performance a lot but using texturepacker it does not really work out since only pro features would help. any suggestions? (other than: go and buy that texturepacker license ... about 50$ isn't that cheap IMHO).
     
    Last edited: Jan 31, 2015
  4. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    do you mean: make animation with sprite sheet or put all sprites in one texture atlas ?

    for animation with spritsheet, i am using http://www.brashmonkey.com/spriter.htm
    it was free for sprite sheets (i dont know what is now).

    for atlas you can just looking for free packer, something like
    https://www.assetstore.unity3d.com/en/#!/content/23276

    i think, but not sure, that sprite sheets or atlasses can reduce the draw calls. But if you have one small game, so it will not be performance killer without using packer :)
     
    Last edited: Jan 31, 2015
  5. 12dollar

    12dollar

    Joined:
    Jan 3, 2015
    Posts:
    18
    I wanted to put all different sprites (currently bunch of png files) into one spritesheet so I have only one png file for idle for example, one for walk and so on.

    I don't have my characters separated in body parts or so
     
  6. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    then try simple packer or just google a bit for something better :)

    i have used simple packer, it was good (but dont forget to switch sprite format from compressed to truecollor befor you are trying to pack something)
     
  7. 12dollar

    12dollar

    Joined:
    Jan 3, 2015
    Posts:
    18
    well using google to find something is what I've been doing the last 6 hours.
    texturepacker seems good but isn't useful if your sprites get red colored or aren't recognized at all.
    too bad even normal sprites can't be used with the free version.
     
  8. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    Last edited: Jan 31, 2015
  9. 12dollar

    12dollar

    Joined:
    Jan 3, 2015
    Posts:
    18
    I cannot use this because it's for textures only. My files are png files which aren't supported
     
  10. vakabaka

    vakabaka

    Joined:
    Jul 21, 2014
    Posts:
    1,153
    strange, i have png sprites too (maked with paint.net). Just tested and it worked.

    imported sprites have default format compressed. Switch it to true collor (or 16 bit), then pack them. Then you can make compressed back.
     
    Last edited: Jan 31, 2015
  11. 12dollar

    12dollar

    Joined:
    Jan 3, 2015
    Posts:
    18
    tried that it said this format isn't supported. but those sprites are png ...
     
  12. funshark

    funshark

    Joined:
    Mar 24, 2009
    Posts:
    225
    PNG files ARE textures. Texture is not a file format, it's just a name.
    If you can't use your pngs into this packer, that means something isn't right with your workflow.