Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Making a button in 3d space face a player without disabling the button functionality

Discussion in 'Scripting' started by CF_Sixdotsstudios, Nov 10, 2020.

  1. CF_Sixdotsstudios

    CF_Sixdotsstudios

    Joined:
    Apr 10, 2020
    Posts:
    92
    Code (CSharp):
    1. public Transform target;
    2.  
    3.     void Update()
    4.     {
    5.         // Rotate the camera every frame so it keeps looking at the target
    6.         transform.LookAt(target);
    7.  
    8.         // Same as above, but setting the worldUp parameter to Vector3.left in this example turns the camera on its side
    9.         //transform.LookAt(target, Vector3.left);
    10.     }
    this is my code for making a button in 3d face my character but it disables the button and it becomes unclickable
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    What do you mean by a button in 3d space? Are we talking about UnityEngine.UI.Button, or something else?
     
  3. CF_Sixdotsstudios

    CF_Sixdotsstudios

    Joined:
    Apr 10, 2020
    Posts:
    92
    I have it on a canvas in 3d. i want it to look at a player at all times but they get disabled when i add this code
    upload_2020-11-10_23-59-32.png
     

    Attached Files: