#Taunts

1 messages ยท Page 1 of 1 (latest)

spare venture
#

@stone lintel done

stone lintel
#

post your question one more time, please

spare venture
#

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");
        }
    }

}```
stone lintel
#

you should create the instance of class Taunts

#

there are many methods to do them

#

I would recommend you to find it with tag

spare venture
#

am i not making an instance at the end in the above script?

stone lintel
#

no

spare venture
stone lintel
#
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>();
}
spare venture
#

okay omw

#

no luck still

#

now i am getting two nullreferenceexception

stone lintel
#

set properly, please

spare venture
spare venture
#

okay so i did this

stone lintel
#

exactly

#

is it so hard though?

spare venture
#

then this

stone lintel
#

yes

#

nice

spare venture
#

and still the same error ๐Ÿ˜ญ

stone lintel
#

what error?

spare venture
stone lintel
#

give full script omt, please

spare venture
#

the taunts one or UImanager one?

stone lintel
#

UImanager

spare venture
#
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");
        }
    }

}
stone lintel
#

!code

novel jungleBOT
#
Posting 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.

stone lintel
#

mark cs, please

spare venture
#
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");
        }
    }

}
stone lintel
#

nice

stone lintel
#

why do you GetInstance()?

spare venture
#

to get the elements of that class

stone lintel
#
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

spare venture
#
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;
    }

}
stone lintel
#
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;
}
spare venture
stone lintel
#

everything should work unless there is no problem with your audios

stone lintel
#

so

#

static

#

I see

#

do what you did then

#

I apologise then

stone lintel
#

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 :\");
spare venture
#

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

stone lintel
#

what do you need to do now then?

spare venture
#

idk the nullreferenceerror is still there

stone lintel
#

you can send me your .unitypackage if you want

#

you write one more time here, pin me, please, @spare venture

spare venture
#

@stone lintel here

stone lintel
#

@spare venture
please, Assets => Export Package (your full project)

spare venture
#

cool

stone lintel
#

thanks

#

I gonna open it when I am back home, if you do not mind

stone lintel
#

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

spare venture
#

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

stone lintel
#

can you make a screen video for me?

spare venture
#

yep

#

one sec

stone lintel
#

how many scenes do you have btw? 1, yep?

spare venture
stone lintel
#

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?

spare venture
spare venture
#

idk why unity isnt allowing me to keep the second scene on same package

stone lintel
#

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

spare venture
stone lintel
spare venture
#

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

stone lintel
#

oh

#

I get it now

#

@spare venture what's player's sprite?

spare venture
#

its just a circle

stone lintel
#

@spare venture do you really need to store all those audioSources with names and ids?

#

I do not really think so

spare venture
#

ID is unnecessary true

stone lintel
#

name is unnecessary too

#

they do have names already

#

so I gonna just delete it

spare venture
#

names as in the taunt string?

stone lintel
#

Taunts is just garbage

stone lintel
spare venture
#

but they are going to be used in the text of UI manager

stone lintel
#

nice audios though

spare venture
#

which i still havent added yet

stone lintel
#

yes

#

so

#

you can just rename audio sources, don't you?

spare venture
#

why do i need to rename the audio sources? ๐Ÿ˜“

stone lintel
#

so you do not really

#

I will just delete garbate Taunts script

#

pin me btw

#

when I am not typing

spare venture
#

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

stone lintel
#

ok ok

stone lintel
#

@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");
        }
spare venture
stone lintel
#

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

stone lintel
#

@spare venture which script ends your game?

spare venture
#

Player

#

The collision

#

Function

stone lintel
#

why does your mouse do not have borders? @spare venture

spare venture
#

It will be played on phone so i won't be needing borders

stone lintel
spare venture
#

Build it

#

Apk

#

Then play it

stone lintel
#

I know

#

you play on pc in unity

#

you must make borders then

#

it's obvious

spare venture
#

Will probably do later on

#

Not the topmost priority right now

spare venture
#

@stone lintel any luck?

stone lintel
#

almost done, I gonna send it then

#

your code is absolutely unreadable @spare venture

#

not only code

spare venture
stone lintel
#

both scenes are trash

#

that's true

#

man

#

did you write your code by yourself?

spare venture
#

Yes

#

From scratch

stone lintel
#

everything by yourself?

spare venture
#

Yep

stone lintel
#

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

spare venture
#

Alright

stone lintel
#

how is your game called?

#

@spare venture

spare venture
#

Escape your family

stone lintel
spare venture
#

Thank you so much...i will be looking into it after I reach home

stone lintel
#

oh

#

I sent empty

#

@spare venture idk how to send it to you

#

it is too big

spare venture
#

Send a drive link then

#

Or transfernow smething

stone lintel
#

@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

spare venture
#

its so goooood

#

@stone lintel thank you

#

but what is this .PlayTount function...neva seen it before ๐Ÿ˜…

#

oh neva mind got it

stone lintel
#

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

spare venture
#

got it got it

#

also how did you make sure that the audio voice matches with the character sprite?

#

@stone lintel

stone lintel
#

@spare venture I did not do it for now

#

That could be done with enums, structs and Linq though

spare venture
#

so right now any random audio is playing to any random charactersprite?

stone lintel
#

to the character you hit

spare venture
#

yep

stone lintel
#

I cannot see it now though

spare venture
#

ya ya np

#

i will figure it out

#

thank you so much for your help

stone lintel
#

@spare venture, do you know what "struct" is?

spare venture
#

yeo

stone lintel
#

I cannot see the code, cause I do not have my computer with me now

spare venture
#

*yep

#

np np

stone lintel
#

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

spare venture
#

cool understood, thanks @stone lintel

stone lintel
#

i hope

#

@spare venture you can send here what you did, when you are ready, though

spare venture
stone lintel
#

sure

#

you do not have to though)

#

as you wish

stone lintel
#

@spare venture can you give me background you used for this game?

#

I have lost it

stone lintel
#

yes

#

I am trying to redo your game from the beginning, cause it's impossible to refactor ๐Ÿ’€๐Ÿ’€

#

give it like unity package, please

spare venture
spare venture
stone lintel
#

sure

#

btw you do not have to create new scene in that game

#

"EndGame" should be UI Panel

spare venture
stone lintel
#

no

#

that's very stupid thing to do

#

with accessing scripts too

#

you cannot find gameObject from another scene

spare venture
spare venture
#

yep thats true

stone lintel
#

if I succeed, I gonna send it to you for look

stone lintel
spare venture
#

i am really dumb....sorry for causing you so much trouble ๐Ÿ˜“

stone lintel
#

haha

#

that's my initiative

#

@spare venture I have some troubles to import that package, resend background folder, please

spare venture
stone lintel
#

oh!

#

yes

#

hahahhaha

#

fond it

#

lol

stone lintel
#

@spare venture do you need to move your background btw?

spare venture
#
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?

stone lintel
#

you can do EnemyController scripts for each enemy though

spare venture
#

alright

#

and what that would include??

stone lintel
#

choose yourself

stone lintel
#

whether to use strucr or script

stone lintel
#

@spare venture give me the text table, please

spare venture
stone lintel
#

oh, no, I have found it already

spare venture
#

you mean the text of the taunts?

stone lintel
#

sorry for bothering u

spare venture
#

no worries no worries

stone lintel
stone lintel
#

@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

spare venture
#

@stone lintel there are too many changes at this point that i dont even recognise my game at this point UnityChanLOL

stone lintel
#

what

#

oh

#

that's the same game though

spare venture
#

like player script has changed

stone lintel
#

yes

spare venture
#

yeah yeah

stone lintel
#

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

spare venture
#

and i havent seen this datatype UIDocument

stone lintel
#

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

spare venture
#

alright!

stone lintel
#

@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)

spare venture
#

understood

stone lintel
#

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

spare venture