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 weXem · Apr 02, 2013 at 01:54 AM · aipathfindingartificialintelligence

need a logical tip for AI

I want object 1 to take object 2 to object 3 as illustrated. alt text

I've tried several methods but they weren't practical because I want it to not depend on the objects positions, also object 2 might be moving.

I don't want a code i just want the logical steps of doing such a thing, just something to put me on the right track.

Thanks in advance :)

illustration.jpg (37.9 kB)
Comment
Add comment · Show 6
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 Shankar · Apr 02, 2013 at 02:09 AM 0
Share

Hey, Lets try it once. write a logic depending on the time if time is increasing, initiate object. or else write a logic in transforms.

avatar image deltamish · Apr 02, 2013 at 04:02 PM 0
Share

Hi so you want to make object 1 to move towards object2 and attach it and then move towards object 3 right

avatar image weXem · Apr 02, 2013 at 08:53 PM 0
Share

it doesn't have to be attached, all i want is to make object 1 move to object 2 and push it towards object 3.

avatar image TonyLi · Apr 03, 2013 at 12:44 PM 0
Share

Attaching is a lot easier than pushing. (See my suggested answer below for a solution that attaches.) If it's attached, you can guarantee that object 1 won't drop object 2. If you're pushing using physics, you need to constantly check that object 2 hasn't slid off of object 1's pushing surface.

avatar image weXem · Apr 03, 2013 at 04:39 PM 0
Share

Thank you, I guess I'll attach them eventually but can I make it so they don't seem attached, for example making the ball rolls when pushed?

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by TonyLi · Apr 02, 2013 at 02:11 PM

I was first going to suggest a finite state machine (FSM) attached to object 1 (your AI agent) as a good way to break up the behaviors (get object 2, go to object 3). But you really only need one "goto" behavior.

Let's say you have a component called Goto that has a Target parameter. Attach it to object 1, and set the Target to object 2.

In Update(), Goto can compute a path to its target (object 2) and update its velocity. If you want to get fancy, you can examine the target's velocity to compute an intercept course. How velocity translates to actual motion depends on how you've implemented motion. If you're not doing animation, you can call LookAt() to face the target, and change the transform.position (= velocity * Time.deltaTime) in Update(). This is just a straight move to the target. You'll need to write or use a path finder such as AngryAnt's Path to move around obstacles.

When object 1 reaches object 2, it could trigger a collider on object 2. Object 2's OnTriggerEnter() method would then:

  1. Attach itself to object 1.

  2. Change object 1's Goto target to object 3 (i.e., go to object 3 now).

When object 1 reaches object 3, it could trigger a collider on object 3 that would:

  1. Remove object 2 from object 1.

  2. Change object 1's Goto target to null (i.e., stay here).

So you really only have two components in this system:

  1. A Goto behavior, and

  2. An OnTriggerEnter() handler that updates the Goto target and attaches/detaches a child object.

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
avatar image
0

Answer by fafase · Apr 02, 2013 at 02:20 PM

Mmm what about,

 float distance = (obj2.position - obj1.position).magnitude;
 // You get the distance between the two and if not claose enough obj1 faces obj2 and then moves towards it
 if(magnitude < range){
    obj1 looks at obj2
    obj1 moves forward
 }else{
    //At this point we are close enough, we parent the obj2 to obj1 that is now "carrying it around"
    obj1 picks up/parent obj2
    obj1 has obj2   // here we change a bool to state that we have obj2 
 }
 // if obj2 is carried then we can apply same process towards obj3
 if (obj1 has obj2){
    obj1 looks at obj3
    obj1 moves forward
    if(distance with obj3 < range )
       end of an exciting game
 }
Comment
Add comment · Show 2 · 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 weXem · Apr 02, 2013 at 03:55 PM 0
Share

I've thought in parenting but I don't it's a practical way since both of them are rigidbodies.

avatar image fafase · Apr 02, 2013 at 04:01 PM 0
Share

is$$anonymous$$inematic = true is your solution

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

14 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

Related Questions

Artificial Intelligence 1 Answer

Creating an Enemy Jet AI 1 Answer

BDI Agent Programming in Unity3D 1 Answer

My model from Blender does not follow the AI script properly! 2 Answers

Tutorials for AngryAnt's Behave 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