#Taunts
1 messages ยท Page 1 of 1 (latest)
post your question one more time, please
NullReferenceException error
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class UIManager : MonoBehaviour
{
public Image familySprite;
public float typingSpeed = 0.1f;
private bool onetime = false;
public TextMeshProUGUI tauntTMP;
public static UIManager instance;
public static UIManager GetInstance()
{
return instance;
}
private void Awake()
{
instance = this;
}
private void Start()
{
Time.timeScale = 1f;
familySprite.sprite = Player.GetInstance().hitSprite;
if (familySprite.sprite.name == "UncleSprite" || familySprite.sprite.name == "GrandpaSprite")
{
int i = Random.Range(1, 11);
AudioManager.GetInstance().source.clip = Taunts.GetInstance().tauntsList[i].audioClip;
AudioManager.GetInstance().source.Play();
Debug.Log("played");
}
}
}```
you should create the instance of class Taunts
there are many methods to do them
I would recommend you to find it with tag
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
am i not making an instance at the end in the above script?
no

private Taunts taunts;
private void Start()
{
// make sure that you have GameObject WITH script "Taunts" and with tag "Taunts", do not make silly mistakes please
taunts = GameObject.FindGameObjectWithTag("Taunts").GetComponent<Taunts>();
}
set properly, please
i have to add this in the above script right?
yes
okay so i did this
and still the same error ๐ญ
what error?
give full script omt, please
the taunts one or UImanager one?
UImanager
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class UIManager : MonoBehaviour
{
public Image familySprite;
public float typingSpeed = 0.1f;
private bool onetime = false;
public TextMeshProUGUI tauntTMP;
private Taunts taunts;
public static UIManager instance;
public static UIManager GetInstance()
{
return instance;
}
private void Awake()
{
instance = this;
}
private void Start()
{
Time.timeScale = 1f;
taunts = GameObject.FindGameObjectWithTag("Taunts").GetComponent<Taunts>();
familySprite.sprite = Player.GetInstance().hitSprite;
if (familySprite.sprite.name == "UncleSprite" || familySprite.sprite.name == "GrandpaSprite")
{
int i = Random.Range(1, 11);
AudioManager.GetInstance().source.clip = taunts.tauntsList[i].audioClip;
AudioManager.GetInstance().source.Play();
Debug.Log("played");
}
}
}
!code
๐ Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/
๐ Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.
mark cs, please
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class UIManager : MonoBehaviour
{
public Image familySprite;
public float typingSpeed = 0.1f;
private bool onetime = false;
public TextMeshProUGUI tauntTMP;
private Taunts taunts;
public static UIManager instance;
public static UIManager GetInstance()
{
return instance;
}
private void Awake()
{
instance = this;
}
private void Start()
{
Time.timeScale = 1f;
taunts = GameObject.FindGameObjectWithTag("Taunts").GetComponent<Taunts>();
familySprite.sprite = Player.GetInstance().hitSprite;
if (familySprite.sprite.name == "UncleSprite" || familySprite.sprite.name == "GrandpaSprite")
{
int i = Random.Range(1, 11);
AudioManager.GetInstance().source.clip = taunts.tauntsList[i].audioClip;
AudioManager.GetInstance().source.Play();
Debug.Log("played");
}
}
}
nice
what is that?
why do you GetInstance()?
to get the elements of that class
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class UIManager : MonoBehaviour
{
[SerializeField] private Image familySprite;
[SerializeField] private TextMeshProUGUI tauntTMP;
[HideInInspector] public float typingSpeed = 0.1f;
private Taunts taunts;
private bool onetime = false;
public static UIManager GetInstance() => this;
private void Start()
{
taunts = GameObject.FindGameObjectWithTag("Taunts").GetComponent<Taunts>();
familySprite.sprite = Player.GetInstance().hitSprite; // idk what you do here
if (familySprite.sprite.name == "UncleSprite" || familySprite.sprite.name == "GrandpaSprite")
{
int i = Random.Range(1, 11);
AudioManager.GetInstance().source.clip = taunts.tauntsList[i].audioClip;
AudioManager.GetInstance().source.Play();
Debug.Log("played");
}
}
}
i would like to get your audioManager
I would be also good if you send me .unitypackage though
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioManager : MonoBehaviour
{
public AudioSource source;
public AudioClip[] tauntsClip;
private int i = 0;
private bool onetime = false;
public static AudioManager instance;
public static AudioManager GetInstance()
{
return instance;
}
private void Awake()
{
instance = this;
}
}
using UnityEngine;
public class AudioManager : MonoBehaviour
{
public AudioSource source;
public AudioClip[] tauntsClip;
private int i = 0;
private bool onetime = false;
public static AudioManager GetInstance() => this;
}
everything should work unless there is no problem with your audios
so no changes here either?
you'd better do like that though:
int i = Random.Range(1, taunts.tauntsList.Count);
AudioManager.GetInstance().source.PlayOneShot(taunts.tauntsList[i].audioClip);
Debug.Log("played :\");
okay so i saw that only one audioclip can be played per source, if we have to do multiple audioclip we need seperate script which allows to do that, so i just change the audioclip component in audiosource in my original script
also i took the random.range(1, 11) because the list is made in such a way that there are different sets of people and their taunt list are different, ideally i should be making seperate lists but for just quick testing purposes i put them in one, so i just need to trigger for 0 to 10th indexed list
what do you need to do now then?
idk the nullreferenceerror is still there
you can send me your .unitypackage if you want
you write one more time here, pin me, please, @spare venture
@spare venture
please, Assets => Export Package (your full project)
back just now, I will try to download this project and figure out the solution
@spare venture, can you please show how to play this game? it throws errors and I would like to know whether I should fix'em or not
start from main scene
your objective is to avoid getting hit by the faces
use your mouse pointer to move around the screen while holding the left mouse button
can you make a screen video for me?
how many scenes do you have btw? 1, yep?
two: main and end scene
you sent me just one scene
it throws error, because it cannot open the scene with index 1
that does not exist, actually
would you like to send me all scenes?
oooooo lemme figure it out one sec..
these are both the scenes tho
this one has the second scene
idk why unity isnt allowing me to keep the second scene on same package
you'd better name those packages properly though
@spare venture 1920x1080 Portrait, yeah?
@spare venture I'd like you to explain me what does script Taunts supposed to do
yep
it is supposed to contain the taunt text and its respective audio
and when and where do you need to use it?
whenever you hit the faces
the taunt will pop up
and its respective audio will be played
which is basically the type of game over scene we are looking at the end scene
its just a circle
@spare venture do you really need to store all those audioSources with names and ids?
I do not really think so
ID is unnecessary true
names as in the taunt string?
Taunts is just garbage
yes
but they are going to be used in the text of UI manager
nice audios though
yes?
which i still havent added yet
why do i need to rename the audio sources? ๐
so you do not really
I will just delete garbate Taunts script
pin me btw
when I am not typing
okay just to note, i will need the taunt audio to be played and the text of the taunt has to match with the audio inside and that has to be pointed to the tauntsTMP of UIManager
ok ok
@spare venture
sorry, bro, but your scripts and inspector are such a garbage

they are unreadable
for human I mean
@spare venture
do you want to play random clip?
it would be better, when you reply, otherwise I gonna do what I want
of live it as it is
and what's that?
if (familySprite.sprite.name == "UncleSprite" || familySprite.sprite.name == "GrandpaSprite")
{
AudioManager.PlayTaunt();
Debug.Log("Taunt was played");
}

Ummm technically no...so the male voice should match with the male-looking sprites
there were so many mistakes, that I have tried to correct all of them and broke the entire game
I am going to correct just what you need now I guess
@spare venture which script ends your game?
why does your mouse do not have borders? @spare venture
It will be played on phone so i won't be needing borders
do you play on phone in unity?
@stone lintel any luck?
almost done, I gonna send it then
your code is absolutely unreadable @spare venture
not only code
everything by yourself?
Yep
ok
you have some skills
though
it does not matter when you work in team
it's such a trash
your canvas for example
you should build your scene and name GameObject so that you understand what they mean then
Alright
@spare venture I have just done it so that you can hear the audio
I did not touch anything else (almost)
so ofc there are some mistakes
thousands of mistakes
if I have sent not correct package, then write me
do not forget to add scenes in Build Settings to avoid errors
also write here or dm if you need smth
its so goooood
@stone lintel thank you
but what is this .PlayTount function...neva seen it before ๐
oh neva mind got it
it's better to do there a function
you can then do enum of family members, for example
and never make several script hokders like "SpawnManager", "GameManager:
place all scripts on the same GameObject
got it got it
also how did you make sure that the audio voice matches with the character sprite?
@stone lintel
@spare venture I did not do it for now
That could be done with enums, structs and Linq though
so right now any random audio is playing to any random charactersprite?
to the character you hit
yep
I cannot see it now though
@spare venture, do you know what "struct" is?
yeo
I cannot see the code, cause I do not have my computer with me now
You should create a struct with fields: "name", "Sprite" and "AudioClip[]"
smth like that
and than a list of struct for each family member
for example Dad has its sprite and an array of his audio clips
@spare venture
cool understood, thanks @stone lintel
yessir, i wont be working today...have an exam tomorrow...so i would be sending you this tomorrow :D
only the sprite?
yes
I am trying to redo your game from the beginning, cause it's impossible to refactor ๐๐
give it like unity package, please
omg why do you need to do that 
interesting though
hold up....need to open up unity now
sure
btw you do not have to create new scene in that game
"EndGame" should be UI Panel
yeah i just thought....its too much happening at one scene...so new scene ๐
no
that's very stupid thing to do
with accessing scripts too
you cannot find gameObject from another scene
if I succeed, I gonna send it to you for look
thx
sure sure
i am really dumb....sorry for causing you so much trouble ๐
haha
that's my initiative
@spare venture I have some troubles to import that package, resend background folder, please
there is no background folder...its just inside the assets folder ๐
@spare venture do you need to move your background btw?
yep
struct AudioTauntsStruct
{
public string nameSprite;
public AudioClip[] audioTauntList;
public AudioTauntsStruct(string nameSprite, AudioClip[] audioTauntsList)
{
this.nameSprite = nameSprite;
this.audioTauntList= audioTauntsList;
}
}```
@stone lintel does something like this work?
yes, that's perfect
you can do EnemyController scripts for each enemy though
the as that struct includes
choose yourself
whether to use strucr or script
@spare venture give me the text table, please
the text table?
oh, no, I have found it already
you mean the text of the taunts?
sorry for bothering u
no worries no worries
yeah, I have found it already
@spare venture
I have done some basics for you when I had time
there might be some problems with names though
also you should add AudioSources to #ScriptsHolder and names for them, because I do not really know, where is daughter, uncle or aunty
there is everything clear in #ScriptsHolder
there are few Tooltips for you in the Inspector too
good luck
@stone lintel there are too many changes at this point that i dont even recognise my game at this point 
like player script has changed
yes
yeah yeah
I have just added borders
that's more correct now actually
cause all the scripts are needed there
you can now script as they were if that's more comfortable for you
and i havent seen this datatype UIDocument
yep
i can instantiate it in the scene
UI smth => UI Document (create in the scene)
that's just to make your game inspector look better
I always spawn something in UI Documents and recommend it for you too
alright!
@spare venture you should now add some affect on your mouse or whatever; work with your AudioClips and drag them into #ScriptsHolder; also you should add and/or change some of your Animations (also drag them into #ScriptsHolder)
understood
though you can use previous version of the game
i would also say it was an interesting game to do
nice revision of 2d games environment too, the main problem was in Z position
@spare venture
by Z position, do you mean the order layer?
