Dropping coins at target point with SFX

Coin Distraction Part 1

Pseudocode

Coin Prefab

Player Script Drop Coin at Point

if (Input.GetMouseButtonDown(1))
{
RaycastHit hitInfo;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hitInfo))
{
Instantiate(_coinPrefab, hitInfo.point, Quaternion.identity);
}
}
You can see the coins on the ground

Only one

if (Input.GetMouseButtonDown(1)&& _coinThrown == false)
{
RaycastHit hitInfo;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hitInfo))
{
Instantiate(_coinPrefab, hitInfo.point, Quaternion.identity);
_coinThrown = true;
}
}

--

--

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Tristan Engel

Aspiring developer that’s self-learning Unity & C# to transition to a career with Unity. I got a passion for creating interactive experiences.