Collectibles - Unity Tutorial

preview_player
Показать описание
In this Unity tutorial we're adding collectible objects to our game

Рекомендации по теме
Комментарии
Автор

Subscribe or I'll place collectibles out of bounds

passivestar
Автор

Very easy to understand, now I can place all my secret gnomes everywhere, thanks! ✨🔥💯

mrpewpewlaser
Автор

Really well presented tutorial. I like that you added a few extra but simple touches (like the rotation of the collectible) Thanks for the tutorial 🙏👌

Tastygraph
Автор

Where was this video when i was trying to add collectables to my game for at least 3 days lol
10/10 would collect again

juliestrator
Автор

Great tutorial! It tells you what you need to know fast.

Only thing I can say is that it seems very complex for being so simple. (But I don't see how you would know that.) What I did was go to my character and add a "gameObject.CompareTag()" line that checks if the player collides with an object tagged with "Coin". After this, it adds 1 to the public coin amount with "coins += 1;" and destroys the other gameObject. Then an extra script on the canvas changes the score text to display the coins. (Although I don't have a total counter, which I may be able to make by counting the number of children under the "Coins" empty object that holds all the coins for organization and coding.)
This also lets me instantiate a particle prefab where the coin was before it's destroyed, allowing for cool coin collection effects. >:D


P.S. - You can use "using UnityEngine.UI" and "using TMPro" at the top couple of lines if you didn't already know

khordie_
Автор

@passivestar I have 15 errors from it :( And it isn't the one that you resolve in EventSystem :(

OfficialKaiVerse
Автор

I really like this series, well done.

scrubetted
Автор

I just noticed that you added the "event system". You forgot to talk about it, cause without the "event system" we can't makes "Action event"

eddytwo
Автор

NullReferenceException: Object reference not set to an instance of an object () (at



plz help :(

TKontent
Автор

Good morning Sir. I really enjoy what you do and I'm becoming more motivated to take unity more serious. First question, how did you learn unity so fast and secondly what courses did you follow Sir?

Douye_Adedeji
Автор

awesome but how do i make a win screen with this?

sirpugstudios
Автор

Hi there! Great tutorial - it works, but on collision, it registers 2 rather than 1? It seems to be a random process, sometimes only going to 1 and other times upon collision jumping to other numbers - does anyone have any ideas? Thanks!

danstastudios
Автор

everytime I restart the level, the collectables duplicate in number, how coul I solve this problem?

Pichi
Автор

terima kasih banyak bang sudah membantu skripsi saya

andrepandia
Автор

hey i have an error. can you please tell me what is wrong? error CS0246
Code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Collectables : MonoBehaviour
{
public static event Action OnCollected;
// Update is called once per frame
void Update()
{


}
void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
OnCollected?.Invoke();
Destroy(gameObject);
}
}
}
//Collecting script.

yourlocalpilot
Автор

Nice video! I am making tutorials aswell :D

quickunity
Автор

im lazy pls send copy and paste of code :(

OakDoubleA
Автор

for the collection code giving anyone a invoke error this is it fixed

using System;
using UnityEngine;

public class Collectable : MonoBehaviour
{
public static event Action OnCollected;

void Update()
{
transform.localRotation = Quaternion.Euler(-90f, Time.time * 100f, 0);
}

void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
OnCollected?.Invoke();
Destroy(gameObject);
}
}
}

iambored_dev
Автор

hi. i love your owrk. but for me it does not work. can you please correct my script?
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class collectableCount : MonoBehaviour
{
TMPro.TMP_Text text;

void Awake()
{
text =
}

void OnEnable() => Collectable.OnCollected += OnCollectableCollected;
void OnDisable() => Collectable.OnCollected -= OnCollectibleCollected;

void OnCollectableCollected()
{
text.text = (++count).ToString();
}
}

yourlocalpilot