Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
avatar image
0
Question by ivangarciafilho · Apr 02, 2017 at 10:05 AM · collisionphysicstriggerdetectionmelee

Full Performance On Melee Combat

Hi, i know that there's a couple of threads around with the same issue .... but none of them reached the "best practice with full performance" ....

I already profilled It and checked many melee systems around Asset store looking for the mostly "right solution"... and i couldn't reach the "pro way" ...

WHAT I'VE ALREADY DONE TO OPTIMIZE:

  1. Created the Layer HealthSystem (that collides JUST with the Weapons Layer);

  2. Created the Layer Weapons (that collides JUST with the HealthSystems Layer);

  3. Created the static Dictionary < Collider, HealthSystem > healthSystemsColliders;

  4. Created the static Dictionary < Transform, HealthSystem > healthSystemsTransforms;

  5. Created the static Vector3 protagonistPosition cached once every LateUpdate and shared with all AIScripts;

  6. Created the public static event OnAttackDelegate OnProtagonistAttack that every AI assings to that, its own CheckForCollision(Vector3 _Blade, float _damage) method;

  7. Created the public static Dictionary < Vector3, HealthSystem[] > battleMatrix that stores every HealthSystem position rounded to Int, then, updated within the dictionary constantly every LateUpdate();

APPROACHS PROFILED:

  1. Sphere collider within "Protagonist" root transform on WeaponLayer, then a script with OnTriggerEnter() and OnTriggerExit() that manages the private "HealthSystems[] closestTargets and just upon Input.GetAxis("Attack") executes healthSystemsColliders[collider].UpdateHealth(damage);

    [Average Precision and Worst Speed]

  2. Physics.OverlapSphere() JUST upon Input.GetAxis("Attack"), JUST on HealthSystemLayer to load private HealthSystems[] closestTargets and then execute "healthSystemsColliders[collider].UpdateHealth(damage)";

    [Average Precision and Speed]

  3. Upon Input.GetAxis("Attack") the event OnProtagonistAttack(BladeTransform.Position, Damage) fires all assigned "CheckForCollision()" of every Active AI accross the Map checking if ((_blade - itsPosition).sqrMagnitude < 3f) then call "itsHealthSystem.UpdateHealth(damage)";

    [Worst precision but just Fast (zero physics)]

  4. Upon Input.GetAxis("Attack") get a vector3 that corresponds to a point 1 meter towards the protagonist's facing angle, round to int the X and Z values, then call : battleMatrix[itsPosition2D].updateHealth(Damage);

    [Worst Precision but The Fastest (zero physics)]

Those tests where 30 AIs against the Protagonist and i don't know if there's something faster that i didn't try yet or something that i could do to improve/balance between "performance and precision"...

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

OnTriggerEnter2D not Working 0 Answers

collider doesnt work the 2nd time 1 Answer

overlapsphere to destroy NPCs on exit 1 Answer

Collision problem when spawning in the collider 1 Answer

Best practice for OnTriggerEnter detection 1 Answer


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