Coleo Carlson

[HELP] i need help with my 2d game code

Recommended Posts

I have an error with my camera code

CODE: https://gyazo.com/e76fce37df9cf2aac3663dc772e62b74

ERROR: https://gyazo.com/f791cf45282c4789f78ea49a806573ce


I also Have an error with my enemy system

CODE: https://gyazo.com/bfd8fb95dda7047d0bb53f294b4ede7e

ERROR: https://www.youtube.com/watch?v=xBjWoV1Z2E4&feature=youtu.be

the enemy is floating down while i want it to hit the block

 

Share this post


Link to post
Share on other sites

1. Player is a null reference, meaning GameObject.Find() failed to find the player and returned null.

2. For simple 2D collision avoid rigidbody physics unless you want something realistic (or a serious shortcut). Look into Physics2D.Overlap methods. If you just want it to work quickly with rigidbody physics, make sure gravity is off and make use of the OnCollisionEnter() callback method

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Announcements

  • Forum Statistics

    • Total Topics
      628365
    • Total Posts
      2982273
  • Similar Content

    • By mivagames
      Hello all,
      We are a small team that would like to introduce our game - “Bondo 2 - Fusion of Domino”. It's "merging game" with levels.
      The testing phase there were many questions. We are would like to hear constructive reaction about Tutorial of our game: very detailed or no, very long or ... etc.
      We would be happy for any feedback.
      Thanks!
      iOS: https://itunes.apple.com/app/id1288081600

    • By Jim Bachalo
      Hi
      Having a huge problem trying to simply implement a working framework for a turn based (each player takes turns) board game using UNET (Unity).
      I have an Eventmanager system I am comfortable with for sending, receiving custom events.
      I want to avoid adding any unnecessary complexity, so no State machine etc.
      Just a Model class
      A Game Controller
      Perhaps a controller for each player?
      And a View for the board and game pieces.

      Not sure whether most of the game logic (calculating score, wins etc.) would go in the Game Controller or Model class.
      Will extend this for use in AR.

      Can anyone help?
      Are there any really useful MVC C# templates that would get me started?
      Any help appreciated!
    • By PistachioPro
      Hi all! Long time no post. We've been on extended hiatus from game development for several years, but came out of hiding to develop a fun little browser game. It's called surviv.io, and you can find it (appropriately) at http://surviv.io. It's strongly influenced by way too many hours spent playing PUBG. Spawn in, grab some loot, and be the last person standing. Please check it out and let us know what you think!


       
    • By Combo-Smooth
      Hi
      I am a game designer currently working with 3 programmers on a Binding of Isaac like game. https://vimeo.com/237454382
      Our aim for the game is mostly to be able to produce a solid playable demo. If we expand on the game, or make a different game will be decided later.
      As of now, we have most of the game's base mechanics implemented, but our art production is slacking behind. We are currently using placeholder art and we'd like for real art to come into action.
      I'm looking for an artist or 2 to help get the art production up to speed. As artist for the project, you will get to decide a lot about how the game's art will look and feel. We want you to be able to put some of yourself in the game and have at the very least a piece you feel comfortable adding to your portfolio. We have not fully decided if we'll be using sprites or pixel art but the choice will largely be left up to the artists. The game will require simple animations for certain enemies so the artist will need to know how to animate.
       
      if you are interested, you can reply to this post or message me on this site.
    • By idzohar
      I am trying to rotate my car sprite just slightly to the left or right depending on input up to a small maximum. When I use this code, the rotation doesn't stop at the maximum i give it. When i try to reset the rotation back to its original state when not pressing any input, the car also jitters between a z axis rotation of 0 and 2.5. I don't understand why the rotation doesn't stop at the given maximums, nor do I understand why its jittering. Can anybody provide me some insight?
              float movementHorizontal = 0f;
              float movementVertical = 0f;
              if (Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D))
              {
              }
              else if (Input.GetKey(KeyCode.A))
              {
                  movementHorizontal = -1;
                  if (transform.rotation.z < 10f)
                  {
                      transform.Rotate(zAxis, 2.5f);
                  }            
              }
              else if (Input.GetKey(KeyCode.D))
              {
                  movementHorizontal = 1;
                  if (transform.rotation.z > -10f)
                  {
                      transform.Rotate(zAxis, -2.5f);
                  }
                  
              }
              else
              {
                  if(transform.rotation.z > 0)
                  {
                      transform.Rotate(zAxis, -2.5f);
                      //transform.rotation.Set(0, 0, 0, 0);
                  }
                  else if (transform.rotation.z < 0)
                  {
                      transform.Rotate(zAxis, 2.5f);
                      //transform.rotation.Set(0, 0, 0, 0);
                  }
                  
              }
  • Popular Now