Sign in to follow this  
Orymus3

Unity 2D or 3D physics for a top-down 2D ARPG in Unity?

Recommended Posts

Hi,

 

I'm currently setuping my project in Unity. It will be a 2D action RPG.

Though all of the visual will be 2D sprites, I'm concerned that I want to implement features such as jumping over certain obstacles, have some bridges pass over the floor at different heights, and it currently feels like using 3D physics behind the scenes would be much simpler, despite the game being entirely 2D from a visual standpoint.

 

Anyone here tried doing anything a top-down game in Unity? What did you use and why?

Share this post


Link to post
Share on other sites

You can use 2D graphics to emulate 3D objects, but it's really not going to work out for you if you're trying to use 2D physics to emulate 3D physics.  Sounds like you already know the answer to your question.

 

That, and unless you're going crazy with the number of objects that interact with one another, the performance gap between 2D physics simulation and 3D physics simulation isn't big enough to justify shooting yourself in the foot over.

Share this post


Link to post
Share on other sites

So, you assessment is that, regardless of the actual visual output (2d in this case), dropping the Z axis is not a sufficient performance-gainer to justify limiting myself.

That being said, it does come with an added complexity that I need to handle to process collisions.

 

I just feel choosing 3d for a 2d game feels like refusing to use a set of tools optimized for most of what I'm trying to do save for a few things, so I end up handling everything in a 'custom' way because of the few situations that would benefit from that support...

Share this post


Link to post
Share on other sites

I'm by no means an expert in Unity so I'd like to recommend a little sodium chloride with this reply, but in my experience using 3D graphics for a top-down or side-scrolling (parallax) 2D game is unlikely to affect performance much. In fact, the effect would probably be an improvement. Here's my reasoning:

 

In any robust game engine or environment, graphics are usually mixed along alpha channels (etc.) during game play -- characters & obstacles layered on a separate background, etc. In 3D, this is complicated with the addition of a Z axis which requires additional depth management including clipping, occlusion, and so on.

 

At the same time, any 3D engine worth a spit will be efficient, meaning it will not waste too many cycles trying to figure out things like clipping when the graphics blocks are basically just flat planes perpendicular to the Z axis. In effect, the game is simply shifting around postcards on which you probably don't want to apply lighting effects, meaning much of the complexity of a full 3D environment is reduced.

 

Additionally, 3D engines tend to boast their polygon rendering abilities so you know roughly what kind of performance you're likely to get. And beyond this, 3D engines often make direct use of graphics hardware which can greatly increase both rendering speed and free up the main processor for other functions (handling A.I., collision detection, etc.) 2D engines usually use the main computer/device processor so they can boast greater compatibility, but at the cost of raw power and speed.

 

In Adobe Flash, for example, we have had robust 2D graphics since pretty much the inception. Many optimizations have been made to the software to make it efficient, and it was pretty darned good until Adobe introduced direct GPU support. As a result, frameworks like Starling popped up that boasted the same capabilities as Flash 2D but with the ability to handle a lot more while simultaneously freeing up the CPU. In other words, Starling is a 2D game engine that uses Flash's newer 3D capabilities, analogous to your question. The answer that Starling provides is quite clear: 2D games can realize significant performance enhancements (plus easier code/effects), by using a 3D engine.

 

Back to Unity, I'm fairly certain that the same GPU acceleration is used which would lead me to believe that you would be better off using the full 3D engine to create a 2D game; the performance improvements alone would be worth it. Also, as you mentioned, 3D engines tend to have a lot of functionality pre-built -- physics, collisions, etc. It's nice to know how these work but if you're more concerned with actually building the game, these topics are probably best saved until later.

 

My two cents smile.png

Edited by Patrick B

Share this post


Link to post
Share on other sites

Thanks, but I think my concern doesn't really lie with performance, but rather, ease of use for game logic (handling collisions, etc.).

Assuming I want to have stuff like jumping and overpass bridges/mezzanines, I felt 3D makes it easier to handle, but that would also mean I need to attach 3d collision boxes to actual 2d sprites, which feels a bit counter-intuitive?

Share this post


Link to post
Share on other sites

Try both, there's no wrong one.

 

Really, you're using Unity, it's really easy to try both approaches, you don't even need to remove one to create the other, just disable the 2D or 3D collision components and enable the others, you don't even have to replace code since each 3D collision callbacks has a different name in 2D (OnTriggerEnter and OnTriggerEnter2D, etc). Setup some test scenes with the things you have in mind (jumping over enemies, different heights, etc) and try them if you're not sure.

 

Anyway, for a 2D game I think I would go with 2D collision detection and use the z axis values or some flags to check if the collision should be considered or not, it doesn't look like too extra work and maybe you can prevent weird bugs related to the 3D collision volume that you wouldn't notice in a 2D view. Also, 3D and 2D physics use a different axis for gravity and that could lead to more weird bugs, so that's another reason I'll do it in 2D.

Share this post


Link to post
Share on other sites


ust disable the 2D or 3D collision components

 

Wouldn't my code still run actual vector2D vs Vector3D ?

I'd still need to change the code to switch between the two, no?

 


Anyway, for a 2D game I think I would go with 2D collision detection and use the z axis values or some flags to check if the collision should be considered or not, it doesn't look like too extra work and maybe you can prevent weird bugs related to the 3D collision volume that you wouldn't notice in a 2D view. Also, 3D and 2D physics use a different axis for gravity and that could lead to more weird bugs, so that's another reason I'll do it in 2D.

Makes sense. I was going to do something along these lines in 2D.

 

Thanks.

Share this post


Link to post
Share on other sites

 


ust disable the 2D or 3D collision components

 

Wouldn't my code still run actual vector2D vs Vector3D ?

I'd still need to change the code to switch between the two, no?

Even in 2D, Unity puts everything in a 3D world, so the game objects would have a position with x, y and z values in both cases (Vector3). You'll always see the 3 components in the editor, and if you change your scene view from 2D to 3D you'll see that the z value is being used.

 

Also, you can have one script that handles 2D collision and another that handles 3D collision so you don't need to change code, just enable/disable those too depending on what you're testing, and then call methods of another script that does the logic you want for a collision.

Share this post


Link to post
Share on other sites


Also, you can have one script that handles 2D collision and another that handles 3D collision so you don't need to change code, just enable/disable those too depending on what you're testing, and then call methods of another script that does the logic you want for a collision.

 

Ok yes, that's what I meant. 

 

Thanks.

Share this post


Link to post
Share on other sites

Use 3d physics. 2d physics in Unity are more catered towards sidescrollers, for example gravity is either x or y axis so you would have to use kinematic rigidbodies and handle jumping yourself. Methods like transform.LookAt() don't work out of the box. etc. I made couple of top down prototypes a while ago, in the end I switched to 3d physics. The performance gain with 2d was so marginal it was not worth it even on mobile.

 

Also, there are things not available with 2d physics, like particle collision detection.

 

 

 

Thanks, but I think my concern doesn't really lie with performance, but rather, ease of use for game logic (handling collisions, etc.).

Assuming I want to have stuff like jumping and overpass bridges/mezzanines, I felt 3D makes it easier to handle, but that would also mean I need to attach 3d collision boxes to actual 2d sprites, which feels a bit counter-intuitive?

 

Forgot to mention that 3d physics with sprites felt a lot more comfortable to me, as you can give volume to the colliders.

Edited by dissid

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

Sign in to follow this  

  • Announcements

  • Forum Statistics

    • Total Topics
      628395
    • Total Posts
      2982433
  • Similar Content

    • By toadvine
      I'd like to start building a 2D game, very small, just pixel art. I know python/javascript/tiny bit of HTML and I've started learning C++. I'm a long way from starting officially, I've just been making mini-projects to practice & drawing up concept art/gameplay storyboards. I'm just wondering if I'm off with the C++ for the game's programming, or if I should know certain things before starting.
      The game would be very small, I just want to get started trying out some actual work before college.
      Some other info: I'm working by myself on this, and going into game design/programming next year for college. I'm a high school student with a few years of experience just working by myself making small projects, drawing up stuff, so I really don't know much and I'd appreciate any tips.
      Thanks a bunch!
    • By Daerst

      SWARMED is a Zombie-themed RPG / RTS currently in development using Unity 3D. We love Dwarf Fortress (though we have no illusions that SWARMED will reach the same level of complexity), roguelikes, old-school point & click RPGs and real-time strategy games. We aim to cross genre-borders here and there and give some twists to the old Martinis every gamer has been drinking since the 1980s, metaphorically.
      Single player, 3D graphics and adjustable top-down camera - old-school RPG / RTS feeling Take control of a core group of survivors after the outbreak Encounter Zombies that are a real threat, no machine-gun massacre. Don't get swarmed! Build a safe zone anywhere with a highly flexible build system: campsite, lighthouse, school, or fence a whole village Grant asylum to other survivors that you meet and make them a part of your community Achieve sustainability in your safe zone and go on supply runs with your survivors
      Development
      The core team of recently founded indie studio Three Eyed Games currently consists of one writer, two artists and two programmers, based in Germany. We are in our mid-20s with professional experience in developing interactive 3D applications with Unity.
      SWARMED will feature both a 'free-play mode' and a campaign with mid-sized maps that leads the player through a story while explaining the gameplay and introducing him / her to the survivors: a core group a few 'hero' characters the player starts with (each one a detailed character with backstory, hopes and dreams), and more 'heroes' (total not more than 20, probably less) that the player can meet on the journey. In addition, randomly generated NPCs (less detailed and not directly controllable, similar to the way Dwarf Fortress handles its dwarves) can join your safe zone – if you let them.
      We plan to release a few 'Origin' prototypes that showcase individual gameplay systems and meanwhile give a gentle introduction to the characters you will meet in the game. Origin I, showcasing the build system and many fundamental elements like character controls and interactions, is finished and will be released soon. Next up, we're working on the dialog system to be presented in Origin II. Get in touch and we will provide more details and a playable version.
      We want you!
      We seriously think you should join the fun! We are looking for:
      Level Designers / Environment Artists, preferably with experience in Unity and procedural asset creation. Design and build maps with interesting visuals and proper pacing. 3D Artists. Our shacks, items and the dead guys' faces could use some plastic surgery. Can you do that? Writers. We have a bunch of characters to detail and a story to write ahead of us. Game Designers. We have a rough game design sketched out that needs improvement and completion. We need a balanced combat system, trees for constructions, workshops and character skills etc. PR & Community Managers, preferably with web development experience. We want to build a community around the game, and we need you to plan and manage this (with the help of the rest of the team, of course). 2D Artists / UX Designers, preferably with Unity UI experience. Our menus still look pretty dull, and we don't like that. We also need concept art for characters and iconic game moments to define their look and feel. Coders. If you know your way around Unity and C#, there are lots of challenging things to be done. You will work closely together with the two programmers already on the team to get going quickly. Please drop me a message or contact info@three-eyed-games.com
    • By sveta_itseez3D
      itSeez3D, a leading developer of mobile 3d scanning software, announced today a new SDK for its automatic 3D avatar generation technology, Avatar SDK for Unity. The Avatar SDK for Unity is a robust plug-n-play toolset which enables developers and creatives to integrate realistic user-generated 3D avatars into their Unity-based applications. SDK users can allow players to create their own avatars in the application or integrate the SDK into their own production processes for character design and animation.
      “Virtual avatars have recently become increasingly popular, especially in sports games and social VR apps. With the advance of VR and AR, the demand to get humans into the digital world is only increasing”, said Victor Erukhimov, itSeez3D CEO. “Our new Avatar SDK for Unity makes it super-easy to bring the avatar technology into any Unity-based game or VR/AR experience. With the Avatar SDK for Unity now every developer can bring face scanning technology into their games and allow players to create their own personalized in-game avatars, making the gameplay much more exciting and immersive.”
      Key features of the Avatar SDK for Unity:
      Automatic generation of a color 3D face model from a single selfie photo in 5-10 seconds (!). Works best with selfies, but can be used with any portrait photo.
      Shape and texture of the head model are unique for each person, synthesized with a deep learning algorithm crafted by computer vision experts
      Head models support runtime blendshape facial animations (45 different expressions)
      Generated 3D heads include eyes, mouth, and teeth
      Algorithms synthesize 3D meshes in mid-poly resolution, ~12k vertices, and ~24k triangles
      Six predefined hairstyles with hair-recoloring feature (many more available on request)
      Avatar generation API can be used in design-time and in run-time, which means you can allow users to create their own avatars in your game
      Cloud version is cross-platform, and offline version currently works on PCs with 64-bit Windows (support for more platforms is coming soon)
      Well-documented samples showcasing the functionality.
       
      Availability
      The Avatar SDK for Unity is offered in two modes - “Cloud” and “Offline”. The “Cloud” version is available at http://avatarsdk.com/ and the “Offline” version is available by request at support@itseez3d.com.
      ###
      About itSeez3D
      At itSeez3D, we are working on the computer vision technology that turns mobile devices into powerful 3D scanners. itSeez3D has developed the world's first mobile 3D scanning application that allows to create high-resolution photorealistic 3D models of people's' faces, bodies and objects. The application is available for iOS and Windows OS mobile devices powered with 3D cameras. In 2016 the company introduced Avatar SDK that creates a realistic 3D model of a face from a single selfie photo. To learn more about itSeez3D scanning software and 3D avatar creation technology, please visit www.itseez3d.com and www.avatarsdk.com.

      View full story
    • By sveta_itseez3D
      itSeez3D, a leading developer of mobile 3d scanning software, announced today a new SDK for its automatic 3D avatar generation technology, Avatar SDK for Unity. The Avatar SDK for Unity is a robust plug-n-play toolset which enables developers and creatives to integrate realistic user-generated 3D avatars into their Unity-based applications. SDK users can allow players to create their own avatars in the application or integrate the SDK into their own production processes for character design and animation.
      “Virtual avatars have recently become increasingly popular, especially in sports games and social VR apps. With the advance of VR and AR, the demand to get humans into the digital world is only increasing”, said Victor Erukhimov, itSeez3D CEO. “Our new Avatar SDK for Unity makes it super-easy to bring the avatar technology into any Unity-based game or VR/AR experience. With the Avatar SDK for Unity now every developer can bring face scanning technology into their games and allow players to create their own personalized in-game avatars, making the gameplay much more exciting and immersive.”
      Key features of the Avatar SDK for Unity:
      Automatic generation of a color 3D face model from a single selfie photo in 5-10 seconds (!). Works best with selfies, but can be used with any portrait photo.
      Shape and texture of the head model are unique for each person, synthesized with a deep learning algorithm crafted by computer vision experts
      Head models support runtime blendshape facial animations (45 different expressions)
      Generated 3D heads include eyes, mouth, and teeth
      Algorithms synthesize 3D meshes in mid-poly resolution, ~12k vertices, and ~24k triangles
      Six predefined hairstyles with hair-recoloring feature (many more available on request)
      Avatar generation API can be used in design-time and in run-time, which means you can allow users to create their own avatars in your game
      Cloud version is cross-platform, and offline version currently works on PCs with 64-bit Windows (support for more platforms is coming soon)
      Well-documented samples showcasing the functionality.
       
      Availability
      The Avatar SDK for Unity is offered in two modes - “Cloud” and “Offline”. The “Cloud” version is available at http://avatarsdk.com/ and the “Offline” version is available by request at support@itseez3d.com.
      ###
      About itSeez3D
      At itSeez3D, we are working on the computer vision technology that turns mobile devices into powerful 3D scanners. itSeez3D has developed the world's first mobile 3D scanning application that allows to create high-resolution photorealistic 3D models of people's' faces, bodies and objects. The application is available for iOS and Windows OS mobile devices powered with 3D cameras. In 2016 the company introduced Avatar SDK that creates a realistic 3D model of a face from a single selfie photo. To learn more about itSeez3D scanning software and 3D avatar creation technology, please visit www.itseez3d.com and www.avatarsdk.com.
    • By Canislupus54
      I'm looking for programmers for an rpg I want to make. If you're wondering what "semi-turn based" means, it means that you take turns, but instead of a rigid back and forth like Pokemon, a timer determines when you can act, a sort of modernization of the classic Final Fantasy Active Time Battle system. Right now, I'm looking for programmers to create a prototype of both the combat system and the movement outside of combat. Preferably for Unity C#. Concept artists, particularly for characters, and writers to help me flesh out the character and story aspects, would also be helpful.
      Here's a concept doc to fully explain things: https://docs.google.com/document/d/1ObDMAUWsndSAJ1EpQGRDxtR8Xl9xPotx89OZ0sgRaIw/edit?usp=sharing
      If you can fill another role and are interested, feel free to let me know as well.
      At the moment, this is purely a hobby project, with no payment planned. If we produce something we feel we can release, then of course we'll work out something for compensation. But, again, don't join this project counting on payment.
      If you're interested, contact me on here, or at jordestoj@yahoo.com . Thanks.
  • Popular Now