Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by unity_mxTWsrmALoWtFQ · Apr 22 at 10:30 AM · gameobjects2d spritesisometricbestpracticeshowto

Proper Setup of 2d Isometric Characters (Best practice?)

First off, I'm having trouble formulating my real question here - it's more of a general "how do I approach this" kind of problem.

I've been dabbling with Unity for a while now, and while the coding parts are clear, I'm having trouble figuring out how to really do things properly when it comes to GameObject setups and such. It seems that everyone has a different approach - I'll try to illustrate my own Problems (might get a bit long-winded):

I'm trying to create a 2D isometric game with an atypical angle (it's not 45°).

The first problem I encountered here, is that the position of the GameObject is not the real position (or "center point") of the character on an isometric plane. I need this "center point", for collisions, path finding, etc. The only solution I found here, was to add a child object that is just a point.

So, my structure now would look like this:

Character A
 - Character A Center

To find the center point, I use it as a parameter "center" on the parent object "Character A".

Already, I have to ask myself if this is a bad approach, but let's continue:

Next, I soon realized that dealing with Animations had their own problems: Certain animations have different offsets. They aren't all perfectly aligned (for example, a sprite sheet for someone standing is less wide than someone kicking). In addition, the center point of the character isn't necessarily the center point of the animation (again, kicking out makes the sprite wider, but the actual center of the character would be where the standing leg is).

Ultimately, I saw myself forced, to create another child object: the "body". So now my Structure is:

Character A
 - Character A Body
 - Character A Center

And again, the "body" becomes a parameter for "Character A".

"Character A" contains all the scripts, like path finding, Seeker, etc.

"Character A Body" contains the Sprite Renderer, Animator, Rigidbody 2D and Collider 2D.

"Character A Center" is just a transform.

So far so good, this seems to work fine, my NPC enemies can walk around, animations are aligned properly, their "center of mass" is properly offset.

But then I realize: I cannot apply this methodology to my Player character.

The key difference here is: My NPC's are being moved by A* pathfinding. This directly moves them, and the path finding script is on "Character A" (the parent GameObject). In other words: the pathfinding moves the parent object (and all children) directly.

My playable character is being moved by RigidBody.velocity; but the RigidBody (the "body") is a child of the parent, which holds the controller. So now, the child is being moved around, while the parent doesn't get moved.

Of course, I could start trying to fix this by just applying the child position to the parent position, but I would expect to find a solution that works equally for all characters on screen without any exceptions for the player character (what if I could suddenly mind-control another NPC in-game? Player controls should be independent of the GameObject structure, right?). Even then, adjusting the parent position to follow the child seems like a very bad solution.

But this brings me to a conclusion I've had long before: I have no clue how things are actually put together in a 2D game like this. I can find tutorials for little parts (how to do pathfinding, how to do dialogue, how to interact with other game objects, collisions, etc) - but my question is, how is all of this actually properly put together? What's a good structure to avoid the issues I've been having? Do "real" games rely on character game objects with dozens of children or just somehow cram everything into one massive game object?

And how do you guys deal with Animator offsets? I've not found any way to offset an animation by x,y without having it inside it's own child - this seems off.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

186 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

isometric view is rendering weird help :O 0 Answers

Sprite animation showing animation above it in spritesheet. 1 Answer

Tilemap : problem rotating and flipping a group of tiles 1 Answer

I can't get my spawner to work! pls help fast. 0 Answers

I accidentally deleted my heart canvas and don't know how to get it back 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges