- Home /
Highlight where the player clicks
Hello, I'm making a game where the player moves by clicking on a point in the world. How do I go about highlighting where the player clicks on the ground?
Answer by IvovdMarel · Jan 13, 2017 at 06:59 PM
'Highlighting' is a pretty vague term, but if you'd like to instantiate something like a particle system where you clicked (or a light, anything really) you'll need to use Raycast.
RaycastHit hit;
if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit, Mathf.Infinity))
{
Instantiate(yourPrefab, hit.point, Quaternion.identity);
}
Hey, sorry for the vague question. I know how to do something like that. I'm meaning something like you have in a game such a Pillars of Eternity where a glowing green circle appears on the ground. I'm assu$$anonymous$$g I'd need a shader for something like that but I know very little about them.
@Arcana96 I'm sure Ivovd$$anonymous$$arcel's answer can still apply. What you will need to do is create a sprite with the highlighted texture on it. Then create it at the position that you click.
However another wait to do this is to create a single sprite the first time the player clicks then move it to the desired location the next times that they click. Save instantiate+destroy time.
Your answer
