Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
This question was closed May 12, 2013 at 12:01 AM by TheDarkVoid for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by TheDarkVoid · May 11, 2013 at 11:02 PM · aidirectionvector math

Determining if something is on the Left or Right of an Object

How can I determine whether something in the world is on the left or right of an object even if the object is rotations. I have a vehicle that i'm trying to create an AI for but i need to be able to determine whether the next waypoint is on the left or right taking into account that the vehicle could be in any rotation. I can't use lootAt or similar functions.

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 IINVENCIBLE · Mar 04 at 03:22 AM 0
Share

the best simple way to determine that, will be with this simple code

//this is a variable of type transfor, which we will use to locate our player or objetc public transform player;

void Start() { //here we asign the player to the variable we created Player = GameObject.Find("Player").GetComponent();

//if player position x is less than the current objetc position x then the player is at the left else it is at the right

     if (Player.position.x < transform.position.x) {  Debug.Log("player is left from object");  }
                         
         else {  shootRight(); Debug.Log("el player esta a la derecha del drowned"); }

1 Reply

  • Sort: 
avatar image
5
Best Answer

Answer by DSebJ · May 11, 2013 at 11:11 PM

By using this: http://forum.unity3d.com/threads/31420-Left-Right-test-function

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 TheDarkVoid · May 11, 2013 at 11:21 PM 0
Share

ahh, the Dot product, completely slipped my $$anonymous$$d, Thank you so much.

Follow this Question

Answers Answers and Comments

16 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

Related Questions

NavMesh Agent Controlled AI Sliding Toward next waypoint 0 Answers

AI create path, help. 1 Answer

Get the direction of an AI Character 1 Answer

Enemy (with state machine) cannot target player!! 0 Answers

How to get a vector as if it were a local position to an object? 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