- Home /
 
Terminal Typing
I'm trying to make a part of the game where you can use a pc and type on it and what not as part of a puzzle but can't figure out how to make it so i can go into the view of the pc(switch camera/ access with a raycast) and then make it so that i can interact with the pc.
 //my current code
 //Raycast.cs
 using UnityEngine;
 
 public class RayCast : $$anonymous$$onoBehaviour {
 
     public Camera fpsCam;
     public float range = 5f;
 
     void Update()
     {
         if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.E))
         {
             Ray();
         }
 
     }
 
     void Ray ()
     { 
         RaycastHit hit;
         if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range));
         {
             Debug.Log(hit.transform.name);
 
             Target target = hit.transform.GetComponent<Target>();
             if (target != null)
             {
                 target.openPcUi();
             }
         }
     }
     
 }
 
 //Target.cs (what will open ui when hit by ray cast
 using UnityEngine;
 
 public class Target : $$anonymous$$onoBehaviour {
 
     public void openPcUi()
     {
         Open();
     }
 
     void Open ()
     {
 //what do i need in hear so that i can enable and disable UI
     }
 
 }
 
 
                  So i have found a way to do it now its just about how
I recommend to create the whole PC interface in an empty scene first. $$anonymous$$ake it work. Then see how you can disable or enable it as needed. That's then what goes into your code you're looking for.
in your open function just enable a separate UI script!
Your answer
 
             Follow this Question
Related Questions
Allowing users to make graphs in game--is this possible? 1 Answer
Raycast and OnTriggerEnter performance 1 Answer
How to turn real life object into gameobject 1 Answer
Terrain trees 1 Answer