- Home /
Question by
HGamer1922 · Aug 17, 2021 at 07:41 PM ·
objectscursorimage target
Detect if Player Look at object with out having cursor,Clicking On Object with out Having Cursor on
I want to make image show up when clicking F on a object, but how can I make the game know if Iam locking at the object with out having a cursor? I used this code to hide it : Cursor.lockState = CursorLockMode.Locked; Cursor.visible = false;
And This code to show image when pressing on the object :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ShowMessages : MonoBehaviour
{
public Image image;
void Start()
{
image.enabled = false;
}
// Update is called once per frame
void Update()
{
}
private void onClick()
{
if (Input.GetKey(KeyCode.F))
{
image.enabled = true;
}
}
}
I need to make the game know that iam clicking/looking at the object and but it at the if statement Is my code right and how can I make the game know if iam looking or pressing F at the object?
Sorry if my English is bad.
Comment
Your answer
Follow this Question
Related Questions
How to output output object in image 0 Answers
Change materials of connecting objects 0 Answers
Swapping Objects 3 Answers
Duplicated objects go crazy at runtime 0 Answers
Camera Following Multiple Objects 0 Answers