Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question World Space Text without movement?

Discussion in 'UGUI & TextMesh Pro' started by alainjiehfeng, May 30, 2020.

  1. alainjiehfeng

    alainjiehfeng

    Joined:
    May 13, 2020
    Posts:
    60
    Hi, is there any way I can get my canvas/text which is set to World Space and tied to the Main Camera, to not move when the camera does? I just want a static/stationary text in a particular 3D position in the world space, and have it stay exactly there, despite the camera moving. Any ideas? :)
     
  2. bitlysub2anf

    bitlysub2anf

    Joined:
    May 8, 2020
    Posts:
    71
    So, you're saying that you want to make the UI Buttons move with the camera?
    If this is what you mean, then:
    Attach the Canvas as a part of the Camera. I think this will work because I used (in 2D) a background that stays with the camera. Let me know if that worked. Also, just in case, I'll search for more solutions.

    Personal Messgae: Hi again ^_^
     
    alainjiehfeng likes this.
  3. alainjiehfeng

    alainjiehfeng

    Joined:
    May 13, 2020
    Posts:
    60
    Hello! :)
    No that's not it, I want it not to move with the camera. Basically I want text in a certain position in the 3D World Space, and have the text stuck there so that it won't move when the camera moves.
     
  4. bitlysub2anf

    bitlysub2anf

    Joined:
    May 8, 2020
    Posts:
    71
    Oh, I get in. Just like it Alto's Odyssey. I know that you may think this is dumb. I am looking for a solution but until then, try giving your text a Rigidbody (Not Rigidbody2D as shown in the picture). And set all the values to zero (also, don't forget to set gravity to zero, or it'll fall). And then freeze all the: X, Y, Z positions.
    Annotation 2020-05-31 124303.png
    Also, set the type to Kinematic
     
    alainjiehfeng likes this.
  5. bitlysub2anf

    bitlysub2anf

    Joined:
    May 8, 2020
    Posts:
    71
    If that does not work try this:
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class TextPosition : MonoBehaviour
    6. {
    7.     void Start()
    8.     {
    9.      
    10.     }
    11.  
    12.     void Update()
    13.     {
    14.         //You can remove the "if" statement, but it'll still work just fine with and without it
    15.         if (5 != 3)
    16.         {
    17.             transform.position = new Vector3(0, 0, 0); //Change the 0s to your desired position
    18.         }
    19.     }
    20. }
    This should continuously transport your text to that position. OR, if both do not work, you can try them at the same time.
     
    alainjiehfeng likes this.
  6. alainjiehfeng

    alainjiehfeng

    Joined:
    May 13, 2020
    Posts:
    60
    Thanks for the solutions, will try. For now I think I found my solution. :)
     
  7. bitlysub2anf

    bitlysub2anf

    Joined:
    May 8, 2020
    Posts:
    71
    Okay, but... For the record, please do let others know which one worked
     
  8. alainjiehfeng

    alainjiehfeng

    Joined:
    May 13, 2020
    Posts:
    60
    Ah yes.
    Well basically, I made a UI text, increased the font resolution, and then used the rotate tool and scale tool to first rotate the text in the World space (should first set the text to World Space), and then scaled and set it in my desired location. :)