Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 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 /
avatar image
0
Question by rickaz · Jan 20, 2013 at 02:51 AM · c#rotationangleobject position

Object position to player position in angle and apply to rotating a gui plane?

 Hello All

 I have the idea to c# script a Player directional indicator, but have know
 idea where to start.

 Plan:

 object 1 - A standard prefab cube as a target to witch the script will apply.

 object 2 - The player, after all, the indicator will help him find his goal.

 object 3 - A plane with transparency texture symbolizing an arrow on screen,
 using a other stationary objects created as a HUD with it's own off player
 camera. (set under the terrain.)

 I need to take a angle from player to target, get the result. Then convert that
 result to rotational movement in degree, and apply it to rotate the indicator's
 plane.

 good in ideas, but not in execution.

using UnityEngine; using System.Collections; public class Target_Indicator : MonoBehaviour { public Transform target; //values that will be set in the Inspector. public float angle = 0; //Create sting, Now we can see it in the inspector. void Update() { Vector3 targetDir = target.position - transform.position; Vector3 forward = transform.forward; float angle = Vector3.Angle(targetDir, forward); } void OnGUI() { float displayValue = Mathf.Round(angle);//Change decimal to hole numbers. //Make a GUI label - position on sccreen - add "angle:" - display the value. GUI.Label(new Rect(30, 475, 150, 50), "angle: " + displayValue.ToString()); } }

 This should at lest give the angle and place on screen, but it through an error:

 Assets/Scripts/Target_Indicator.cs(13,16): warning CS0219: The variable `angle' is assigned but its value is never used

 any help would be appreciated.

 Rick 
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

0 Replies

· Add your reply
  • Sort: 

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

9 People are following this question.

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

Related Questions

Flip over an object (smooth transition) 3 Answers

Random angle 1 Answer

Location in relation to other objects rotation 1 Answer

How to rotate an object to a specific angle with angularVelocity? 0 Answers

Make object only rotate in 90 degree increments 0 Answers


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