• 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 ghostreddy · Jun 30, 2012 at 05:48 PM · directionguitexturenavigation

suggesting the ball to safe direction off being hit using guitexture

Hii Since i am working with a ball game & looking for some good solution for below problem.

  1. the enemy ball move randomly around the scene if enemy balls coming closure to player ball then we need to suggest the safe direction to the player ball by displaying the guitexture arrows like left,right,up,down like that......Eg: if enemy balls are moving closure to player ball in +z axis then the arrow should suggest the safe direction either left or right.

Thanks!!!!

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Berenger · Jun 30, 2012 at 08:43 PM

The escape direction is going to be the cross vector between up and player -> enemy.You should check if the direction is avalaible (no walls) and if it's not, invert it.

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 AlucardJay · Jun 30, 2012 at 09:08 PM

This is an easy way to check which object is closer, and what side of the player the object is on. You can attach this script to any gameObject (or the camera), then drag-and-drop the player and enemies into the Inspector.

 #pragma strict
 
 public var Player : Transform;
 public var Ball_1 : Transform;
 public var Ball_2 : Transform;
 private var closestBall : Transform;
 private var goLeft : String = "Go Left";
 private var goRight : String = "Go Right";
 private var guiString : String = "";
 
 function Update()
 {
     if ( (Ball_1.position - Player.position).magnitude < (Ball_2.position - Player.position).magnitude )
     {
         closestBall = Ball_1;
     }
     else
     {
         closestBall = Ball_2;
     }
     
     if (Player.position.x < closestBall.position.x)
     {
         guiString = goLeft;
     }
     else
     {
         guiString = goRight;
     }
 }
 
 function OnGUI()
 {
     GUI.Box(Rect((Screen.width/2) - 50, 10, 100, 30), guiString);
 }

http://docs.unity3d.com/Documentation/ScriptReference/Vector3-magnitude.html

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 ghostreddy · Jul 02, 2012 at 06:42 PM 0
Share

@alucardj: Thanks for the help....pls check the below doubt http://answers.unity3d.com/questions/277983/activate-animation-on-android-device-rotation.html

avatar image AlucardJay · Jul 02, 2012 at 06:50 PM 0
Share

If your question has been answered, please mark it =]

Left of the answer, there is a : Thumb Up : a number : Thumb Down : Tick(check) $$anonymous$$ark :

Please tick the answer you have accepted, as it helps people in future searching the 'site and reading questions. Also good to know that you have an answer that worked, and gives you and the person karma points !

I work with iOS, not Android, but I shall take a look at the question. I am just starting out myself, and have learned alot from the many other helpful people here, so if your question is good you should have no trouble getting some answers. Good Luck and Have Fun =]

avatar image ghostreddy · Jul 20, 2012 at 08:26 PM 0
Share

@alucardj: how can i add the destination like placing a box and adding that game object as a destination & the arrows should guide the safe way off being hit to the player to reach that location.

Thanks for ur help buddy.....i really wanna hit thumb up but i am restricted i mean i can't hit thumb up now for that i need to create a new a/c which i am about to create....

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Restricting NavMeshAgent to not travel in diagonals 0 Answers

cycle joystick navigation similar to penelope. 0 Answers

Minimap North Direction 1 Answer

Passing speed and direction to an Animator Controller 0 Answers

Reduce Draw call for Multiple GUI Textures with same Texture 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