Answer the question
In order to leave comments, you need to log in
Open panel on keypress?
Unity project, room with multiple objects. Task:
- We approach the first object, press Enter and one panel opens (with text, say).
- Approach the second object, press Enter and the second panel opens.
- etc.
How can this be implemented?
Thanks for any help.
Answer the question
In order to leave comments, you need to log in
This is usually done by writing code.
What part of the task are you having trouble with? How to detect Enter, or what?
I would venture to suggest that you want to show the player descriptions of the objects they are looking at. In this case, the problem is solved something like this:
0. On objects that can be considered, we hang a class (let's call it Describable
), which contains the actual description. Also, for optimization, such items need to be placed on a separate layer.
1. We hang a script on the camera that makes a raycast in Update:
var fwdLook = camera.TransformDirection(Vector3.forward);
RaycastHit hit;
if (Physics.Raycast(camera.position, fwdLook, out hit, checkDistance, layer)) { // layer должен быть тот самый, где у нас предметы, checkDistance настроить по вкусу
var describable = hit.transform.GetComponent<Describable>();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question