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 Jesterhead · May 07, 2012 at 05:39 PM · collisionai

Box Collider and AI

I am using a simple waypoint script that takes the AI around a small circle of 8 waypoints. The script works fine without any collision detection, but when I add a collider of sorts (Like a box collider) the script stops working. Here's my script below: #pragma strict var grid : Transform[]; var speed : float = 5.0; var current : int; function Start () { } function Update () { if(current < grid.Length){ //variables to determine movement var target : Vector3 = grid[current].position; var moveDirection : Vector3 = target - transform.position; var velocity = rigidbody.velocity; //if close to the waypoint, increase current if(moveDirection.magnitude < 1){ current++; } else { velocity = moveDirection.normalized * speed; } //set the rigid body velocity to move rigidbody.velocity = velocity; } else { current = 0; Could anyone please help me so that I can run my AI script with a physics collider attached to my AI?

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 Jesterhead · May 07, 2012 at 07:04 PM 0
Share

I have a rigid body attached to the two AI characters that also have box colliders attached to them. With this script attached, when I run the game, the characters float for a few seconds and then they stop moving all together. I get no errors and when they do not have any colliders on them what so ever they move in a circle, following exactly what the script intends them to do.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · May 07, 2012 at 05:44 PM

Do you use a rigidbody without a collider? A rigidbody always needs a collider, or where do you attach the BoxCollider? I guess your rigidbody just get stuck on another collider?

What exactly does "stops working" mean? Does it still move but too slow / the wrong way / ...? Do you get errors? What exactly changed when you attached a collider.

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 Jesterhead · May 07, 2012 at 06:34 PM 0
Share

The AI characters both have a box collider and rigidbody on them. Without the box collider, the AI does exactly as the script intends and moves in a circle using the waypoints. With a box collider on them, they float for a few seconds and then stop moving all together. There are no errors.

avatar image Bunny83 · May 07, 2012 at 07:23 PM 0
Share

Are you sure that the waypoint can be reached? I mean the pivot point of your character has to be able to reach the waypoint ( < 1 unit) in all direction (x, y, z)

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Need AI script that makes object follow the player (and collidors work) 1 Answer

Why is my AI not thinking the collisions fast enough? 1 Answer

NavmeshAgent vs Character Controller = Absolute Unity Failure? 1 Answer

AI - Raycast collision and follow player 1 Answer

Enemy Ai Problem with the collider and gravity 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