How to create a simple coin counter in your Unity game? Easy Unity 2D tutorial.

preview_player
Показать описание
#UnityTutorial #SimpleUnityGame #unitycoincounter #unitycoin
In this video I will show you how to create a coin counter for your Unity game.

You are very welcome :-)

First we add a player represented by funny smile facew hich will picking up golden coins. This player moves with help of C# script where we get directions to move in Update method by pressing arrow keys and pass this data in FixedUpdate method to RigidBody2D component as a horizontal and vertical velocity. Coins player picks up have circle collider with isTrigger option checked and a C# script so if player collides with the coin the number of coins value is increased by one and coin is destroyed. Also we create a coin counted UI text game object with C# script attached that controls the number of picked up coins by storing it in coinAmount public static int variable.

What this video is about and what it can be used for also: unity 2d tutorial,
unity tutorial, coin counter unity, How to create a simple coin counter in your Unity game, how to create coin counter unity, coin counter UI unity, add coin unity, pickup coin unity, pick up coin unity, pick up coin game, pick up coin tutorial, unity coin, how to pick up coin unity, coin UI unity, ontriggerenter2d, coins counter text unity, unity coin collecting, learn unity fast, unity tutorial, how to make games with unity, unity how to make game, unity how to make 2d game, not as good as brackeys but good as well.
Рекомендации по теме
Комментарии
Автор

Why are you speaking onto my left ear???

lordvir-clashofclansandmor
Автор

For these who using TextMeshPro and getting "NullReferenceException: Object reference not set to an instance of an object
ScoreText.Update () (at

you need to go like this:

using TMPro; (instead of using UnityEngine.UI;)

public TextMeshProUGUI text; (instead of Text text;)

void start ()
{
text = (instead of text = GetCompoment <Text>();
}

now u continue by this tutorial hope it helps

PS: please pin this comment to help others :) btw great tutorial, keep going;

patrikpatrik
Автор

I had some issues with my left ear and my doctor advised me to watch this video. Thank you for your help.

rm
Автор

I got a null reference error. And my text for the score is not updating. How can I fix this?

kyleplair
Автор

thank you so much you really helped my left ear

Beaubacon
Автор

how can i safe this value and show it in an other scene as score?

seanjanke
Автор

Assets\CoinScript.cs(9, 9): error CS0103: The name 'ScoreTextScript' does not exist in the current context

rassill
Автор

YOU DON'T KNOW HOW MUCH THIS HELPS All I can say is THANK YOU <3

I am curently in a game jam and i needed this SOOOO much
Thanks again

Cjajfbf
Автор

Sometimes (totally random i think) it adds more than 1 coin to the counter. I dont know why pleas help.

marvin
Автор

When I launch Unity i have an error : NullReferenceException: Object reference not set to an instance of an object
ScoreText.Update () (at

can someone helps me ?

minna
Автор

Hi, trying to reapply this for 3D project. I applied trigger. What am I missing? Its not working, although I suspect its due to the 2D collider written section in the script. Also, can I make it so that I would have to collect the object via button press within proximity?

solidslish
Автор

Question, what can I do so wherever my character dies in the scene the score reset to 0 without losing the coins collected on the past levels?
Thanks!

rodsal
Автор

How can I keep the coins worth even if I go to the game from the beginning

מיליםלשירים-עמ
Автор

My character wont move once I activate the scoretextscript under the Cointext child. I'm not using your movescript though. (Won't work with my game style). Everything else works, including the coinscript.

David-eljw
Автор

Hello there!
How can i make the score restore to 0 when i move to another scene? Thanks in advence :)

molecular_master
Автор

Hey, I have applied this to my game, and I am getting only one problem. I keep getting a glitch where I will sometimes get two points instead of one point for each coin. Can you help me fix this?

divyhsingh
Автор

how do you save the coin count between Scenes

wynot
Автор

Pls help me it says the type or namespace Text could not be found I copied script exactly the same

Adeel
Автор

My player disappeared when I collided with the coin.

Never mind. Thanks man!

thnPffr
Автор

next step is to get a hearing check on your right ear

nicholasa
visit shbcf.ru