• Content count

  • Joined

  • Last visited

Community Reputation

278 Neutral


About cmac

  • Rank

Personal Information

  • Interests
  1. Regarding range comparison, Mathf.Approximately checks if the two floats are within an epsilon, which has been ideal for me in most cases:
  2. Not a C++ expert (yet), but this is what I've gathered from college + research: Include headers in headers as little as possible in general. At best compile times are slowed, at worst you end up with obscure circular includes and namespace pollution. Forward declare in headers when you need to declare a pointer to a type, but do not need access to any of its information within the header file. Include the forward declared class in the .cpp file so you can access its data and operate on it. This is the easiest way to deal with classes including each other, in my experience at least. In your Game/GraphicsDevice example, Game.h will need to include GraphicsDevice because it is declared as a value type, but since GraphicsDevice only declares a pointer to Game, it can be forward declared and then included in the cpp file. I've personally found these two rules really easy to follow and handles the majority of all cases, though cases like template classes can get tricky if their implementations are inline.
  3. Fonts dissapearing in Unity!Help!

    Is your text box too short for the new font size's height?
  4. use of shared_ptr

    The parameters for std::make_shared are the arguments for the template type's constructor, you should not be using new.
  5. From the API (getKeyChar): KEY_PRESSED and KEY_RELEASED events are not intended for reporting of character input. Therefore, the values returned by this method are guaranteed to be meaningful only for KEY_TYPED events. Your KeyTyped method looks like it should work so I'm not sure what's up with that (unless you have caps lock on or something?), but otherwise if you're not printing/logging the actual characters that are inputted and are instead mapping keys to actions, you should use getKeyCode() + keyPressed/keyReleased instead anyway.
  6. I think that's a reasonable way to think of the heap. Avoid it unless you need to create an object that outlives the current scope, or to circumvent stack overflow with large objects.
  7. Not to hijack this thread (hopefully this contributes to the discussion topic), but is that generally always the best option? I'm using a very similar system to OP (vector<Renderable*>), and sorting using insertion sort on every push_back() to enforce draw order. I thought about discarding and re-populating renderables every frame, but I assumed the cost of sorting the entire array every frame was much more expensive than insertion sort on insert + std::erase(std::remove_if()) on removal. I guess I'll just have to run some performance tests and see for myself.
  8. I haven't used Photon in a couple years but did you take a look at the demo (vikings IIRC) that comes with the package? IIRC that contained everything I needed to get it off the ground.
  9. SendNext() and ReceiveNext() to read/write data to the stream
  10. C# Unity Timing deltaTime should cover everything you need by the sounds of it EDIT: also take a look at Invoke and coroutines, but be mindful of which is best for a specific use case (
  11. Android The main game loop FPS independent

    At first glance your code looks fine, can you be more specific about how it's inconsistent across different devices? You haven't provided your drawing code, but note that if you are using Repaint, the screen will not be repainted immediately (it will wait for the next RepaintManager cycle). If you are using Repaint, try changing it to paintImmediately.
  12. Blank Programmer.

    Games often look like complete garbage with placeholder art before the real assets are obtained. For example, Braid before the artist: Braid after the artist:
  13. [HELP] i need help with my 2d game code

    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
  14. Blank Programmer.

    My situation isn't too dissimilar from yours, and as a result I've recently been programming 10+ hours a day of C++ and avoiding Unity entirely. But everything jpetrie said is on the mark - use the right tools for the job and don't worry about it otherwise. I'm only grinding C++ because I really enjoy working in it, and it's the most common denominator in terms of game dev skills so I figured it'll help with landing a junior position. Despite that, there are plenty of Unity specific positions out there, or that just desire Unity skills on the side, so it's never a bad skill to have. I had one teacher who was a complete anti-Unity elitist in college and it had a weird effect on me (he wasn't an ignorant gamer like most Unity haters), but don't let those people get to you. If the Unity workflow works for you and lets you create high quality games in a reasonably timed dev cycle, just do it.
  15. Wierd bug

    Read up on memory management; clearing the vector causes the pointer to go out of scope, but the data is never deleted, resulting in a memory leak. Overall though read Alberth's post in detail, seems like he nailed the problem down.