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 unity_pFMLXdYDm2xLrg · Feb 20, 2019 at 06:17 PM · collisiontriggergetcomponentcollision detectionnavmeshagent

Change NavMesh Speed after collision/trigger just for 1 object

Hi guys, nice to meet u.

I'm going to tell u my Shakesperian Question.

I have more than 1 enemy with the same Script, and that's my problem: My player has a script that stops the enemy for 5 seconds after the Spacebar is pressed and if it is in a specific range. I detected this range creating a GizmoSphere and his radius and using it in my "StopTheEnemy" script with a float variable.If the distance between the player and the enemy is less than the MaxRadius of the gizmosphere, the script change the NavMesh Speed of my enemy to 0. It works with just 1 enemy, and when i try to add more than one, all the enemies stops ( i interact with some variables too in the enemy script ).

So, i know that i wrote with a little caos in so i'll tell u just my question: I want to try to change the NavMeshSPeed just for the enemy that collides with my player's GizmoSphere without change something in other enemies with same script and components. There's a way to take the component of the collided/triggered object inside the function?

THANK U SO MUCH !

and have a nice day =) ,Hi guys, nice to meet u.

I'm going to tell u my Shakesperian Question.

I have more than 1 enemy with the same Script, and that's my problem: My player has a script that stops the enemy for 5 seconds after the Spacebar is pressed and if it is in a specific range. I detected this range creating a GizmoSphere and his radius and using it in my "StopTheEnemy" script with a float variable.If the distance between the player and the enemy is less than the MaxRadius of the gizmosphere, the script change the NavMesh Speed of my enemy to 0. It works with just 1 enemy, and when i try to add more than one, all the enemies stops ( i interact with some variables too in the enemy script ).

So, i know that i wrote with a little caos in so i'll tell u just my question: I want to try to change the NavMeshSPeed just for the enemy that collides with my player's GizmoSphere without change something in other enemies with same script and components. There's a way to take the component of the collided/trigger with the gizmoradius of the object inside the function?

THANK U SO MUCH !

and have a nice day =)

Comment
Add comment · 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 jstopyraIGG · Feb 20, 2019 at 06:58 PM 0
Share

How are you finding which enemies to stop? GizmoSphere just draws a sphere, it doesnt check for collision. You need to either loop through all your enemies and calculate the distance to the player, or you can use Sphere Overlap.

https://docs.unity3d.com/ScriptReference/Physics.OverlapSphere.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by unity_pFMLXdYDm2xLrg · Feb 20, 2019 at 08:01 PM

i get the radius of th gizmos and i give it to a float variable, then i calculate if the distance from player/enemy is less than the radius. I can change that but i still need to know how to interact with just the enemies insied the range that i need without touching other enemies that i place in the game and without adding to the script all the enemies on the map =/

Comment
Add comment · 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

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

167 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

Related Questions

Trying to make object turn red OnTriggerEnter 0 Answers

Triggering sounds on collision?,Rigged Character animation collision 2 Answers

Stop collision of NavMeshAgents 0 Answers

2D collision not registering 1 Answer

OnCollisionEnter and OnTriggerEnter not working 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