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 Eco-Editor · Jun 04, 2017 at 09:55 AM · transformtargetai problems

Changing AI's target in run time

Hello,

I want to know how I can redirect a new point to be the target during run time. I have a BOX with a trigger, once the FPC is colliding with it, it becomes the target of the AI. I've created a child object of the BOX, and now I want the AI to have this child object as a new target and not the FPC.

For example, I have an enemy that is chasing the player once it hits the trigger, but instead I want it to chase the cake that lies near by.

This is how I'm thinking logically:

  1. assign the BOX as an object using the script it has on it (EDIT: assign a class to gameObject).

       private ShelfEvent shelf;
         
         public Void AssingNewTarget(Vector3 target, Transform point)
         {
             shelf = GameObject.FindGameObjectWithTag("Product").GetComponent<ShelfEvent>(); 
                     if (shelf != null)
                     {
             TODO: assign new target
                     }
         }
    
    
  2. reference the child objects of the BOX, and see if they active/ not null?

  3. Then say that FPC transform is no longer relevant but there's a new relevant transform?

I'm literally having a hard time with each step of the way.

EDIT: I've decided for start to assign a regular object and then move to it's child.

Comment
Add comment · Show 2
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 toddisarockstar · Jun 04, 2017 at 03:28 PM 0
Share

why not just make a new empty gameobject as a child of the FPC and have the AI permanently follow it.

Then when you get your trigger. simply re-parent your empty marker to the cake and it's position.

avatar image Eco-Editor toddisarockstar · Jun 04, 2017 at 08:35 PM 0
Share

Hi! I love your idea and going to try it!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by JC_SummitTech · Jun 05, 2017 at 07:24 PM

If I understand correctly, you have one player, and N other actors(AI). Whenever the player collides with a trigger, the actors should "target" that trigger.

The way I would do that, is use a MessageHandler singleton. have all AI register to a TargetChanged delegate in the MessageHandler. When the player collides with a trigger, call MessageHandler.TargetChanged(collidedObject.transform);

Your AIs will then be notifiec and can have their target changed appropriately.

Comment
Add comment · Show 1 · 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 Eco-Editor · Jun 06, 2017 at 07:44 AM 0
Share

Hi @JC_SummitTech I'm having a Final State $$anonymous$$achine for the AI's and haven't thought at all about what you're suggesting, but it seems very interesting. This is a whole new way of coding for me. I really think it could be a delicate solution for many lines of code and looking to read more about it. Can you reference any reading material or tutorial?

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

80 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

Related Questions

(C#) Follow target (script) transform target PREFAB 0 Answers

Look at object when it is in the range of the player 0 Answers

C# Probability of Transform Colliding 1 Answer

Look Behind Me While Still Moving Forward 1 Answer

Set Y position same as another object 2 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