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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Making my first game: 2.5D Side scrolling shooter question

Discussion in 'Getting Started' started by james_m_russell, Jun 26, 2015.

  1. james_m_russell

    james_m_russell

    Joined:
    Jun 2, 2015
    Posts:
    25
    a little background: I know how to code and also produce music. My brother and I are learning how to 3D model, and I've done a few Unity tutorials. We've partnered up to start making games (and have some huge plans) but for now we're keeping it small.

    So I have a simple design question:

    for a side scroller game, that automatically moves forward (left to right).

    should the camera move forward through the level with the player
    or
    should the camera and player stay at origin and the level scroll past the player?
    or
    Does this even matter?

    thanks in advance for the help.
     
  2. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    From the player's perspective it doesn't really matter because it's all relative. But it should be easier to just move the camera because it is only one object to move.
     
    JoeStrout likes this.
  3. james_m_russell

    james_m_russell

    Joined:
    Jun 2, 2015
    Posts:
    25
    cool thanks. got that sorted out (my camera moves, my players movable area is computed by the camera location and i have leading and trailing destruction triggers set off screen that destroy missed enemies and missed blaster bolts).

    so my next question:

    i want my enemies to fly onto the screen in a set pattern. going off the space shooter tutorial, it really just drops asteroids in a strait line. I'm looking for S's or another more complicated movement pattern. ex: flys in on the bottom right of screen and then S up to the top left).

    is this something you would use the animator for? I'm planning on maybe 3 enemy spawn points just to the right of the camera. so the movement would start at one of the spawns regardles of it's original transform? (in other words, the transform values would have to be computed based on where it started, and not hard coded, if that makes sense?).
     
    Last edited: Jul 2, 2015
  4. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    My basic shmup I built first had an enemy that came in from one side, went off the other, moved up a bit then scrolled back across -sort of in a rectangle pattern. The 2nd lot moved in a sin-wave back & forth across the screen. The third rose up from below the bottom edge, shooting as it rose, reached a point at the top (below the score) then moved back & forth across the screen shooting. I did it in 2d without animation but you could just as easily do it in 3d. Playing with trig curves gives nice patterns & you can always code them to change patterns when certain co-ords are reached
     
  5. james_m_russell

    james_m_russell

    Joined:
    Jun 2, 2015
    Posts:
    25
    i played a bit with the animator and was able to get a ship to fly in a pattern. I was animating the transform position though, so when the camera and player scrolled to the right the new ships were animating off screen to the left.

    maybe i'll look into moving them on a sin wave and see if that gets me where i need to be.
     
  6. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    I think you will find they will still be moving off screen when the camera moves as the position of the enemies is updated from their previous position. Personally I think it would look a bit weird if they moved in a pattern around the way the player moved.
    my understanding of the side scroller is that the enemies are either placed in the game & then they just move until you get to them, they are placed & remain still until you get close & trigger them, or they're just spawned when you hit triggers. If the player can't go backwards then you can destroy them when they reach a certain position off screen in relation to the camera/player position so they aren't taking up resources once they are beyond where the player can interact with them.
    From your post I think you could also try having spawn points that are linked to the camera so they are always just offscreen & always move with the camera. That way you can spawn the enemies just offscreen, have them move in a pattern towards the player & then destroy them when they are offscreen again, have some that reach a point behind the player & then maybe move back until they reach a point in front of the player & keep circling that way etc. Empty game objects take up almost no space so you could have lots of them if you wanted so you can spawn all different enemies at all different screen heights moving in all different patterns. Or you could have a few & rely on movement scripts to move them to the start pos while they are still offscreen, or you could try to put basic AI in if you wanted more intelligent enemies but starting with fixed movement patterns is probably easier.

    Anyway, have fun. You can always try to post up a demo if you want some feedback or ideas as it is always easier once people actually see/play a game.
     
  7. james_m_russell

    james_m_russell

    Joined:
    Jun 2, 2015
    Posts:
    25
    yup...this is exactly how i have it setup. I guess my issue with how I did animation was not clear.

    so the animator recorded the transform location (X and Y). so it started at (15,15) and animated to (10,10) in a curved line. When the player, camera, and spawn points progressed through the level on the X axis at say 175 (and camera view angle is about 30 units), the very first point the enemy jumped to was 15 because that was the value of X in the animator. in effect it spawned at the spawn point, and instantly teleported behind my destruction trigger off the left side off of the screen. Maybe the enemy needs to spawn as a child of the spawn point object so the animation would be in relation to the spawn point instead of global transform?

    I do have this game hosted as a webplayer, but I'm going to back and completely reworking the player health, enemy health, damage scripting. once that is done i might be ready to post for ideas. :)

    its definitely fun. when I get stuck on things like this, I shift focus to another aspect so i don't get too hung up and stall.
     
    Last edited: Jul 13, 2015
  8. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    Ok, good luck. I'm not up to using animation to move my stuff yet so I just use standard rigid body forces or transforms