Hi I’m not looking for a step-by-step guide necessarily here as I realise the importance of learning much yourself as you go, from tutorials, etc but would appreciate if someone could guide me in the right direction. I’ve been developing a space simulation game for a little while now and have created a star system with ships and stations in it etc. but having a problem trying to work out how to be able to click on a station and then display it on screen. The screenshot below shows the type of thing I’m talking about from an older game. I tried looking at raycast scripting but although I could see how to get it to report the mouse location it did seem like that was more pointed towards shooting rather than actual targetting from anything I could grasp.
What do you mean by “display on screen” ?
Do you mean display that you’ve clicked/selected it , or do you mean show another image of it?
As for the actual just clicking part, I would suggest trying the IPointerClick/Down/Up interfaces.
You can implement the interface on a script attached to the station. So long as it has a collider, and you add a physics raycaster to your camera, you’ll be able to receive notifications of when the mouse is down, up, or clicked.
Oh, you must also have an event system in your game.
Ok will try messing with that for a little bit. The display that I’ve clicked/selected it is what I’m after. Thanks.
Ah okay, sure, if you have a script with some information about the base, then when you click it you could display that. Makes sense. Maybe clicking on nothing hides it and clicking on a new one replaces the old one…
Are you familiar with those interfaces? They need “using UnityEngine.EventSystems”…
I have an EventSystem already in the scene yes and I’ve got a very basic understanding of what they do. I’m learning a lot as I go but reading the manual helps me with most things, I just couldn’t find any information on this particular subject. From what I understood though I believe that the easiest way to display the name of a planet/station/object is to use the tags in Unity and it just display that. Unless that’s wrong?
I guess it would depend on how much info you want to show. To me, the idea of a script is nicer, because you could have a name, some description/info, possibly stats, or other text… I have no idea… depends on the depth of those objects in your game. With just a tag, you could have some data based on the tag, yes.
That kinda make sense?
That is a good point about the scripts. To be honest I was hoping to just have some very basic information shown on the initial target, probably just the name and distance to object and then the ability to click on an information button for more info which I guess then could be written as a separate script to show information based on current target. I would worry that any extra information on the basic screen might be too cluttered in some cases but I don’t know.
Sure, I can understand that. I guess the reason I repeat about the script is that without one, you really only have : a) game object name, b) tag. So not a lot to work with But just getting name + distance could be done with that information only.
In any event, that was slightly off-topic The main thing I hope you can work out is clicking and getting “something (some info)” from the clicked object in response , and to your screen. After that , do what ya like …