Toss A Coin To Your W-… Security Guard. (Part 5)

In this post, I will be exploring the “Fake” method mentioned in my last post: Using Unity VFX to mimic a tossed coin flying.

Vincent Taylor
2 min readNov 15, 2021

Today’s Objective: Create the alternative “Fake” coin arc using the coin toss mechanic from my previous posts.

As mentioned in my previous post, I call this the “Fake” method because I am using a Trail Renderer to simulate a real coin flying, rather than an actual coin, like used in the “Real” method. Each method has it’s own pros and cons, so I tried out both.

The Code:

Building on the “PlayerControl” class from Part 4, I need some more variables:

Now, in the “TossCoin” coroutine, I add functionality for either the “Real” or “Fake” method. After the toss arc is calculated:

The “SpawnCoin” method does what the name implies. This should NOT be confused with the “SpawnAndTossCoin” method.

The “StartCoinVFX” coroutine is pretty simple, and similar to the initial arc calculation. It just uses a different arc resolution, because more = more smooth.

For anyone wondering, the “pointNumber — 8” is a quick-fix, because the VFX wasn’t reaching the target point at the same time the real coin spawned, and I haven’t found a better fix yet.

The Result:

The “Real” Method
The “Fake” Method

Either version looks good, I think. It’s up to you to choose which would work best for your projects. Personally, I think I might keep the “Fake” one for now. Fortunately, switching is as simple as 1 click.

--

--

Vincent Taylor

Unity game developer / C# Programmer / Gamer. Australian (Tasmanian) indie games developer for 10+ years. Currently looking for games industry employment.