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 Royall · May 02, 2014 at 11:22 PM · navmeshagentworldtoscreenpoint

Bumpy WorldToScreenPoint

Hi guys,

I am trying to display a character name (to begin with) above the player (third person). I use WorldToScreenPoint(transform.position) in onGUI...

The player is walking with a navmesh agent on a navmesh baked terrain (point & click).

The name is following the player as desired but the name shakes a lot when I walk the player.

Any fix for this?

Thx

Comment
Add comment · Show 3
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 robertbu · May 03, 2014 at 12:50 AM 2
Share

If the following object is bumpy but the character is not, and if the text is following the character using a script rather than parent child, then try moving the following code into LateUpdate().

avatar image Royall · May 04, 2014 at 12:22 PM 0
Share

There is no following object... Just an ongui on the player drawing a text string.

avatar image Gruffy · May 04, 2014 at 01:10 PM 0
Share

I have to agree with @robertbu here , throw all your camera and object following scripts into LateUpdate(). I notice below robertbu`s suggestion, you stated there is no following object but the scenario you are describing in your question denotes the very characteristic features you say are not there.

Could, for clarity, you please post your code so we may actually be able to view it and quicker identify your issue. we would need to see any code attached to your gui object, any relevant code attached to your player object, and if you can, a quick screenshot of your Hierarchy panel in the Unity ID$$anonymous$$

Thanks bud, sorry its not a resolve as of yet, but if you post what I mentioned above, we may be able to assist you an awful lot quicker than taking mere stabs(though i`m pretty sure whats been suggested will most likely turn out to be your issue), if you get me.

Take care bud Gruffy

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Royall · May 04, 2014 at 01:18 PM

Ok, I figured it out myself... I needed to ceil the screenpoint values with Mathf.CeilToInt

Here is the code:

 function OnGUI() {
     var namePlatePos : Vector3 =  Camera.main.WorldToScreenPoint(transform.position); 
     GUI.Label(Rect(Mathf.CeilToInt(namePlatePos.x), (Screen.height - Mathf.CeilToInt(namePlatePos.y)), 100, 50), username);
 }
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 robertbu · May 04, 2014 at 01:47 PM 0
Share

@Royall - I'm glad you solved your problem. Based on your 'solution' I hope you realize that without your code, there is no way we could have answered your question. And your question as asked does not point to this as solution. $$anonymous$$ore complete information would help us help you with future questions.

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

22 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 avatar image avatar image

Related Questions

How to queue NavMeshAgents on entering a tile in Unity (based on path distance to tile)? 0 Answers

NavMeshAgent collision not working with player 2 Answers

NavMesh Agent rotation problem 3 Answers

WayPoints navMeshAgents help 0 Answers

enable/disable navmesh agent and obstacle same object (player) 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