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 /
avatar image
0
Question by ragnaros100 · Sep 03, 2013 at 12:40 PM · c#enemydetectionhitbullets

DetectSphere - No physics

I have this problem:

My player spawns alot of bullets and these bullets need to detect if they've hit an enemy. I've tried to use a method where I filter the closest enemy out of an array of all the enemies that are on screen, but that is way too performance heavy (It's a mobile game) so I tried some Raycasting, but that is just too unreliable.

Is there some sort of way you can check if an object is within a certain radius of another object without using colliders and the earlier described function with arrays?

I refuse to use any kind of unitys physics because, as said, I've only had bad experiences with physics based hit detection. So please don't answer if you're just gonna say "use triggers and colliders"

Thanks in advance.

Comment
Add comment · Show 4
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 meat5000 ♦ · Sep 03, 2013 at 12:42 PM 0
Share

I think Overlap Sphere function detects bounding boxes.

Edit:

NOTE: Currently this only checks against the bounding volumes of the colliders not against the actual colliders.

This won't access CollisionInfo, I believe, so won't be performance intensive. But ok, if you don't want to use colliders at all.

avatar image ragnaros100 · Sep 03, 2013 at 12:47 PM 0
Share

OverlapSphere Returns an array with all colliders touching or inside the sphere.

I dont use colliders as said. I was thinking about a sphere that checks for points in a 3D space and not boundries of a collider

avatar image robhuhn · Sep 03, 2013 at 01:08 PM 0
Share

That re$$anonymous$$ds me at the find neighbor algorithm used for flocking to increase performance.

http://ceur-ws.org/Vol-204/D05.pdf

http://www.wseas.us/e-library/conferences/2012/CambridgeUSA/$$anonymous$$ATHCC/$$anonymous$$ATHCC-06.pdf

It's also described in the book "AI Program$$anonymous$$g by example - Chapter 3"

avatar image Fattie · Sep 03, 2013 at 01:20 PM 0
Share

guys ---- it's just "distance", it's that simple! heh

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Fattie · Sep 03, 2013 at 12:59 PM

"Is there some sort of way you can check if an object is within a certain radius of another object without using colliders and the earlier described function with arrays?"

It could not be easier. All you are saying is the distance.

So, to check if bullet BB is "within a sphere" of say 5 meters, from house HH,

Simply look at the distance from HH to BB.

If you are unfamiliar with noting the distance in a game engine like Unity, check the doco here http://docs.unity3d.com/Documentation/ScriptReference/Vector3.html

{Note - this is exactly what PhysX does in that situation! it's that simple.}

"I refuse to use any kind of unitys physics"

That is absolutely irrational, because basically "every single video game" of all genres, uses PhysX.

"I've only had bad experiences with physics based hit detection" it would be difficult to name, software, other than an OS, more widely used than PhysX. Essentially the entire entertainment industry uses it. So you probably just had some simple mistake. You just will struggle to work on games, whether career or hobby, if you can't familiarise yourself with the simple physics in Unity!

BTW you mention performance in para 1. We only make mobile games and for something as simple as bullets, it is inconceivable performance could be an issue. You must be doing something very unusual.

Comment
Add comment · Show 4 · Share
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 Sisso · Sep 03, 2013 at 01:09 PM 1
Share

I make @Fattie my words. Your sort algorithm to find nearest enemy is probably heavier than a raycast for all enemies :P

The main problem is, the physic is a very complicated and powerfull too, you need fully understand if want to use correctly. It is the same as graphics, you can do the same scene with 900 draw calls slow in PC or with 20 draw calls at 60fps in a mobile if you full understand what is happening.

avatar image ragnaros100 · Sep 03, 2013 at 01:11 PM 0
Share

I did look at distance between object 1 and object 2. It's just that my sort algorithm was too performance heavy. And please don't be mean, I was simply asking

avatar image Fattie · Sep 03, 2013 at 01:21 PM 0
Share

Just for the record .......... why do you need a sort ?

avatar image ragnaros100 · Sep 03, 2013 at 02:25 PM 0
Share

so I can check the distance between two objects. I have more than one enemy y'know

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

21 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

Related Questions

The name `target' does not exist in the current context 1 Answer

How to make enemies flash on hit 2 Answers

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

2d raycast enemy detection 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