Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Games [WIP] SHMUP : Learn basics

Discussion in 'Works In Progress - Archive' started by 9uile, Mar 17, 2016.

  1. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    Hello All !!

    After followed the whole tutorial (Space Shooter), i decided to begin the experience to TRY making a game.
    So, let's go. I'll made a shmup !
    (in TATE, Vertical view)

    In fact, my main goal is to understand how unity works.
    Don't hesitate to share your experience with me because i'm an absolute newbee !
    Wrong way, best practices, useful links...
    (Only 3 weeks exp. in unity)

    I will try to make small steps regarding my free time (as all workers with a family in fact :) ).

    So, Here we go !!!

    -------------------------

    I open a new 3D project

    Camera :
    --------
    set transform position (0,0,-5)
    set transform rotation (0,0,0)
    set transform scale (1,1,1)
    set the 'main camera/clear flags' to 'Solid Color' and 'background' to 'black'
    set the 'main camera/Projection' to 'Orthographic' and 'size' to '10'
    File/save scene as 'Level1'
    In project vue, create a folder '_scenes' and put 'Level1' inside the scene folder.

    Directional Light :
    ------------------
    Set 'intensity' to 0

    Background :
    ------------
    create a folder 'textures' and put 'grid.png' inside.
    grid.png is a file to see if i can see all the playground in both orientations (vertical and horizontal)
    Create '3d object/quad', rename 'quad' as 'background'
    Put grid.png on 'background'
    set transform position (0,0,0)
    set transform rotation (0,0,0)
    set transform scale (11.25,20,1) the ratio 20/11.25 corresponds to the scale value of 1920/1080 resolution.

    Build the project (to test the background)
    ----------------

    Build the game (windows build)
    167Mo ??? AWESOME !!
    Is that normal an empty project is so big ???
    i kown that there a BG file but ...

    test landscape mode -> ok


    test portrait (flipped) mode -> ok


    Is there a way to make a menu to specify unity to rotate the screen (without doing it with Windows) ?

    It's seems to be a good start ?
    That's all for today.
     
    Last edited: Jan 17, 2020
  2. RichardKain

    RichardKain

    Joined:
    Oct 1, 2012
    Posts:
    1,261
    You've successfully taken a 2D grid texture, stretched it across a quad, and then centered it in the screen so that it will scale properly, dependent on how the screen is rotated. This is a good start. If the approach you're planning on taking is to use a renderTarget texture, than you're well on your way. But a more efficient approach might be to work on scaling the rendering viewport. (performance-wise)

    If you're okay with the render-target approach, I would recommend testing out different grid textures that reflect the different rendering resolutions you could expect to see. You're going to want to have a decent idea of what this will look like at those resolutions. Also, you can tell from your current grid that it was originally supposed to be square, instead of rectangular. The vertical stretching is probably not going to be desirable in the final version. Even if you want to go for a retro aesthetic, horizontal pixel stretching was far more common.
     
  3. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    I'm not sure to have well understood because i'm not talking fluent English.
    If you mean that i've strech the grid file, it was not the case.
    The grid file has a 1920*1080 resolution.
    I have scale it to be viewed by the orthographic camera which size is set to 10 (as in the space shooter tutorial)

    Is that good ?
     
  4. RichardKain

    RichardKain

    Joined:
    Oct 1, 2012
    Posts:
    1,261
    Yes, that's fine. I am a bit curious why the 1920*1080 grid image file features vertically stretched rectangles, instead of squares. Squares are normally used for this sort of thing. The corner bracketing definitely makes it appear that the texture isn't being stretched. You might want to adjust the grid's image to feature squares instead of rectangles. It makes it easier to judge distances on the texture.
     
  5. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    ok, you're right. I'll do it tomorrow with squares :).
    In fact, i did a 10*10 grid and strech it to the hd res.
     
  6. RichardKain

    RichardKain

    Joined:
    Oct 1, 2012
    Posts:
    1,261
    Yeah, it can be a little difficult to divide up a grid evenly with the aspect ratio that 1920x1080 gives you. It's possible, but far from standard. Generate a 16x9 square grid and you'll be good.
     
  7. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    Today,

    - Modifying the grid file -> 16*9 square grid -> OK

    - Blender first try




    - Put a (ridiculous) ship in the scene.



     
    theANMATOR2b likes this.
  8. RichardKain

    RichardKain

    Joined:
    Oct 1, 2012
    Posts:
    1,261
    Yeah, looking good! You're on your way.
     
    theANMATOR2b likes this.
  9. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    I added a playercontroller script on the ship and it can move and be stopped by boundaries to not going outside the game area.
    I build and then the game lags??
    I don't know why because i use the same script that the spaceshooter tutorial and there is no lag when i build this tutorial.
    I solved this by adding time.deltatime in the script.

    But now, i have the same problem with a bullet.
    I add a quad, and put on it a spin script.
    No lag problem when spin script is uncheck but when it is checked, the ship and the spinning bullet lags on the build game( no problem in editor).

    Below the spin script :
    Code (CSharp):
    1. Public class Spin : MonoBehaviour
    2. {
    3. public float speed =10f;
    4. void Update()
    5. {
    6. transform.Rotate(Vector3.forward, speed*Time.deltaTime*100);
    7. }
    8. }
    What could be wrong ?
     
  10. grimmdeveloper

    grimmdeveloper

    Joined:
    May 22, 2013
    Posts:
    5
    If you want to add your own logic for time, then you can slow down time (slow-mo) Example

    public float TimeScale = 1f;
    public float Speed = 10f;
    public float Normalize = 100f;

    private void Update()
    {
    transform.Rotate(Vector3.forward, TimeScale * (Speed * Normalize));
    }

    then as you hit play and adjust the TimeScale value in the editor, you'll see the object slow down and speeds back up.

    if you'd like to wait for the frame to finish you can still use

    TimeScale * ((Speed * Normalize) * Time.deltaTime);
     
    Last edited: Mar 24, 2016
  11. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    Thank you for your response.
    Well, it is not really that i want to do. Maybe (*100) puts you on the wrong way...
    I wonder why after the build, my game lags while it was ok in unity editor.
    My spin script is however very simple.
     
  12. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    today's updates :

    I have finally resolved my problem (lags after build).
    I really don't know why, but it works well after restarting from scratch.
    (same spin script ??!!!)
    I'm happy but it seems weird...

    The scene now contains :
    - a ship with (an autofire Twinshot) YEAH!!!
    - a (low) spinning bulletEnemy



    next things, hum ....

    - add boundaries to destroy bullets out of the game area (or disabled, if pooling)
    - add pooling on player's bullets
    - add a static enemy to shot on me (this famous spinning bullet)
    - add colliders

    Any ideas for next things to deal with ?
     
  13. MinhDao

    MinhDao

    Joined:
    Oct 28, 2013
    Posts:
    155
    Enemies spline path, bullet hell, parallax scrolling background, boss...
     
  14. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    Thank you MinhDao ! I put these things in my to do list.

    I finally clear a problem by spending a lot of time searching in Unity and the web :
    Only one bullet on screen and when i build the scene i saw little 'jumps' during the movement.

    I was upset by this fact, yeah really upset ARGGHHH !!! :) . Because, with a powerful gfx card in 2016, i can't believe that a unique bullet's sprite movement can't smooth !!!

    So i share my solution because i saw during by search people who have the same issue. Note that in editor, there are still a few 'jumps', not after the build.

    In edit/project settings/time :

    Fixed Timestep : 0.01666667
    Maximum Allowed Time : 0.03333333
    Time Scale : 1

    In edit/project settings/quality :

    V Sync Count : Every V Blank

    I don't say it's THE SOLUTION, but it's mine :).
    (and i'm happy to found it)
     
  15. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    I'm asking myself how to deal with sprites.
    I want to use a sprite who looks like pixelized.

    Two ways, what's the best ? (for performances in unity)

    1. Have a small 8x8 sprite and scale it (4,4,4,) -> 32x32
    Or
    2. Have a 32x32 ( artificially pixelized in photoshop ) and import it in unity with a scale (1,1,1)

    I read that we have to avoid as possible to use scale in unity but create artifical pixel sprite make the sprite file bigger...

    What's your tips regarding your experience ?
     
  16. RichardKain

    RichardKain

    Joined:
    Oct 1, 2012
    Posts:
    1,261
    Personally, I wouldn't scale the objects, but adjust the camera. If you're going for a pixel style, that pixel style should probably be consistent across the screen. If that's the case, scaling individual objects would be far less effective than simply adjusting the camera.

    The important thing to think about for pixel-sprite style is the shader you are using. You will want a shader that renders pixels with nearest-neighbor hard edges. This will maintain the chunky sharpness of a classic pixel style, even if you have to rotate the sprite.

    If you are dealing with a case where only a single sprite needs to be of a pixel style, then I would just scale/stretch it. As long as you're not doing it everywhere it probably won't effect performance that much.
     
  17. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
  18. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    I wondering how to manage the bullet's direction.
    Should it be a script attached to the enemy or to the bullet ?
    In my logic, an enemy have :
    - a mouvement
    - a kind of bullet
    and
    - a shoting target (not just forward but also targetting player or others gameobjects)

    In some of exemple i've found, the target's script attached to the bullet.
    I think that i could be more logic to be attached to the enemy.
    Am i right ? (logic may be different that unity logic scripting)
    Maybe not if i want that the enemy will be able to shot different types of bullets...

    1 . So, the script who declare the target should be on the enemy prefab or on the bullet prefab ?

    2. How can i use lerp to set the player as the bullet's destination ?
    (i don't want a homing missile but i want that each shot moves in direction to the player even if he moves between two shots. I think the name is 'aiming bullet')

    3. I'm interesting in homing missile too. I've found some examples scripts but how can i make a missile stall instead of destroying the missile GO ?

    Well, a lot a newbie questions !! :)
     
    Last edited: Apr 4, 2016
  19. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    Update about point 2 :
    It's ok now to aim and shoot the player :
    Code (CSharp):
    1. using UnityEngine;
    2. public class SmoothBulletPosition : MonoBehaviour
    3. {
    4.     private Vector3 targetPosition;
    5.     public float smoothFactor = 1;
    6.  
    7.     void Start(){
    8.         targetPosition = GameObject.Find ("Player").transform.position;
    9.     }
    10.  
    11.     void Update(){
    12.         transform.position = Vector3.Lerp(transform.position, targetPosition, Time.deltaTime * smoothFactor);
    13.     }
    14. }
    But the bullet is stopping on the screen at the previous player's position. (targetPosition in Start function)
    Is it possible to use the player as 'direction' and add some distance to the bullet's destination ?
     
  20. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    i guess you could use transform.move instead and make a vector from your pos to the player pos and use that as the movement vector maybe? Just a guess here though : )
     
  21. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    Test with an enemy :
    first death (colide with enemy)
    second death (colide with bulletenemy)
    third death (enemy shooted :) )
    last death (colide with bullet enemy + GAMEOVER)

    Enemy shoot are static at the moment.
    I need to solve the fact that the bulletplayer through the enemy but destroyGO don't work with pooled objects
     
    Last edited: Jan 17, 2020
  22. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    UP !! (no need to create a new topic)
    I'm back in unity !!

    I'm trying to learn basic skills to made a shmup.
    I'm not ready to make a whole game so i try to learn step by step the essentials mecanics.

    Here is a video of my first attemps :



    Please tell me what i should do next !!!
    Thanks !
     
  23. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    Here is a new video :
    bullet & homing missile
     
    Last edited: Jan 29, 2020
  24. jamespaterson

    jamespaterson

    Joined:
    Jun 19, 2018
    Posts:
    390
    Looks pretty cool! Why not have a go at adding a scrolling background, e.g. a starfield? Or maybe explosions when the enemy or player is destroyed?
     
  25. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    Thank you jamespaterson. I put 'scrolling background' and 'explosions' on my todo list !
     
    jamespaterson likes this.
  26. 9uile

    9uile

    Joined:
    Mar 11, 2016
    Posts:
    32
    Hi! New update.
    I worked on enemy fire. This should cover a wide range of situations.
    I did take a lot of time but if i make a shmup with S***ty shoots, well ... it will be a S***ty shmup ...

    Enjoy !
    Do not pay attention to the calculation of the fps at the top left corner, it messes when I capture the video from unity.


    Thank you for giving me your opinions as usual!
     
    jamespaterson likes this.