Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
This question was closed Sep 19, 2014 at 02:15 PM by Josh Naylor for the following reason:

Too subjective and argumentative

avatar image
0
Question by rm-square · Sep 19, 2014 at 02:13 PM · programmingattackcomponentsarchitectureunit

Component based architecture Unit, AI, Health, Attack

I've read several articles about component-based programming. It's very difficult for me to make such an component-based architecture, because i'm coming from the OOP site.

What i want to achieve: A Unit, that has health, damage, attackRange, detectionRange of enemies etc. This unit spawns and walks to the enemy base. If it detects an enemy, it shall kill the enemy and then continue to walk to enemy base and attack it.

Now i created several components:

  • Unit - has all the attributes like health armor, damage,...

  • Health - Reduces the health

  • Detection - detects enemies with the onTriggerEnter function and notifies the AI to change state in attacking/hunting/walking/dying/waiting mode

  • AI - handles the states and sets the walking destionation with a NavMeshAgent

  • Attack - attacks, if in attacking mode

Now on a first look, they are quiet independent, but then they get connected all together and i receive the opposite of a decoupled architecture. The Attack script calls Detection to get the targeted enemy. The Attack script needs the unit to get all the values like damage and attack range. The Attack Script needs the AI to change the state to WalkingMode after killing an enemy...

And this way somehow all scripts are somewhat coupled again and i have to require my script a lot of others: [RequireComponent(typeof(AI),typeof(Unit),typeof(Detection))]

It seems for me pretty impossible to realize my intention in a decoupled way.

How do you realize decoupling? How would you organize this components? Would you create more components? Would you let it, as it is? What am i doing wrong, that i can't get decoupled components?

Comment
Comments Locked · Show 1
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
avatar image Josh Naylor ♦♦ · Sep 19, 2014 at 02:15 PM 0
Share

Whilst this is a great thought-out question which we certainly appreciate here on Answers, this question would be much more suited for the forums. http://forum.unity3d.com/

This would be more suitable for people to discuss and share their thoughts.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Are there consequences to exceeding Serialization Depth? 0 Answers

How do I dynamically generate scenes? 5 Answers

Several Questions about MVC pattern 0 Answers

Component architecture problem 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