private void LookAt() { //Ray ray = playerCam.ScreenPointToRay(Input.mousePosition); Ray ray = new Ray(playerCam.transform.position, playerCam.transform.forward); RaycastHit hit; if (Physics.Raycast(ray, out hit, maxDistance)) { if (hit.collider.CompareTag("Interactable")) { currentController = hit.collider.GetComponent <OutlineController>(); if (prevController != currentController) { HideOutline(); ShowOutline(); prevController = currentController; } } else { HideOutline(); } } }
private void Update() { // Ray of the mouse from the camera Ray ray = cam.ScreenPointToRay(Input.mousePosition); // Launch a raycast with this ray if (Physics.Raycast(ray, out RaycastHit hit, highlightRange, ~wallLayer)) { Debug.DrawRay(ray.origin, ray.direction * 1000, Color.yellow); // Check if we hit something if (hit.transform == null) { return; } // Get the outline controller of the object that we hit currentOutlineController = hit.collider.GetComponent <OutlineController>(); // Check if the object has an outline controller if (currentOutlineController == null) { return; } if (previousOutlineController != currentOutlineController) { HideOutline(); ShowOutline(); } previousOutlineController = currentOutlineController; }
private void LookAtRay() { Ray ray = cam.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); RaycastHit hit; if (Physics.Raycast(ray, out hit, dist)) { cursorPos = hit.point; if (hit.collider.CompareTag("GravInteract") || hit.collider.CompareTag("GrapplePoint") || hit.collider.CompareTag("Armour") || hit.collider.CompareTag("Knife")) { currentOC = hit.collider.GetComponent <OutlineController>(); if (prevOC != currentOC) { HideOutline(); ShowOutline(); } prevOC = currentOC; } else { HideOutline(); } } else { HideOutline(); } }
private void HideOutline() { if (prevController != null) { prevController.HideOutline(); prevController = null; } }
private void HideOutline() { if (prevOC != null) { prevOC.HideOutline(); prevOC = null; } }
private void Awake() { if (_instance != null && _instance != this) { Destroy(gameObject); } else { _instance = this; } material = GetComponent <Renderer>().material; }
// Start is called before the first frame update protected virtual void Start() { outline = gameObject.GetComponent <OutlineController>(); }
private void Awake() { _outlineController = GetComponent <OutlineController>(); _resourceNode = GetComponent <ResourceNode>(); }
void Start() { instance = this; }
// Use this for initialization void Start () { outlineController = GetComponent<OutlineController>(); }
private void Start() { gridManager = GridManager.instance; outlineController = OutlineController.instance; }