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 Naveen Kumar · May 15, 2014 at 09:39 AM · unity 2d2d ai

How to implement 2D Ai Wandering with 8 - directional movement using Perspective Images in unity 4.3 ???

Hi, My requirement is to move a 2D characters with perspective view images has to wander in game area by choosing dynamic path and according to that the AI character has to switch the
animations based on its current direction and Ai character has to get collision between Ai Character, Ai and Player Character , Ai to Static Obstacles, Moving Obstacles .......

What i done till now is , AI chooses the random Way point and based on its direction it switches the animations and using Ray-cast AI detects the collision with static obstacles, but the problem here is with the Moving Obstacles since AI is casting the ray in one direction, some times AI character was walking on the obstacles like moving cars ..

So please tell me how to solve this problem ???? Thanks in advance

For Better UnderStanding I am giving you the link of what i done so far . If you observe we can find the AI character flickering (that was due to repeated call for choosing new way point )

Here is Link https://dl.dropboxusercontent.com/u/70903877/SuicideBomber/Build.html

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by fafase · May 15, 2014 at 09:43 AM

You could a trigger sphere collider attached to the player so when the car enters the collider, you perform an action.

You could get the car to slow down, and the character to either stop if the car is on the front or speed up if he is about to get hit.

Comment
Add comment · Show 3 · 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 Naveen Kumar · May 15, 2014 at 10:53 AM 0
Share

Thank u for answer , But I already attached the collider to the AI Character and ray-casting with both the Car and AI character . And when car ray hits AI collider car stops for some time and moves and when AI character ray hits colliders its chooses its new path to move . But problem is I am Ray-cast only in one direction , some times players entering into the Cars Collider

avatar image fafase · May 16, 2014 at 07:27 AM 0
Share

maybe get your raycast to sweep in front of the player. For instance, place three empty game objects attached to the player, one on the front and one on each side by 45 or 90 degrees.

 public Transform [] rayPoint;
 
 for(int i = 0; i < rayPoint.Length;i++){
    Vector3 direction = rayPoint[i].position - transform.position;
    // Use the direction in Raycast
    if(raycast){
        // Check the i value to deter$$anonymous$$e which has hit
        // Do something
    }
 }
avatar image Naveen Kumar · May 17, 2014 at 05:26 AM 0
Share

Ya yesterday i tried to rotate the ray in z - direction using the animation clip but i am unable do that .. Could you please tell me how to ray-cast the rays in -45 and 45 degrees to a directional vector where AI character moves. Thanking you for your reponse

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

20 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

Related Questions

What's causing this in my 2D AI script? 0 Answers

Inventory System Unity 0 Answers

Unity 2D Sprites cost many draw calls 1 Answer

Player Vision Radius In a Top Down 2D Game. (Alpha maps?) 2 Answers

Predict next rigidbody position based on velocity 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