#help with difficulty system

1 messages · Page 1 of 1 (latest)

hazy token
#

Does anyone know why it doesn't work?

#

i need help 😿

gaunt dock
#

tenemos el mismo error ahora mismo bro jajaja

hazy token
#

como le hago

#

y nunca respondió...

autumn tinsel
#

The error is saying it cant find it

hazy token
#

yes but what can i do?

autumn tinsel
#

Make sure you spelled everything right. Make sure that component is on what you are trying to access

hazy token
#

I wrote everything correctly, I don't get any error inside the vs code

autumn tinsel
#

your GameObject name has a space in it?

#

show your hieracrchy in scene

hazy token
autumn tinsel
#

show the generador in inspector

hazy token
hazy token
#

se fue para siempre 😿

gaunt dock
#

te deseo fuerza amigo

autumn tinsel
#

hey sry had an update

#

lemme look through this

#

Hey so heres my advice

#

Give this Generador a unique Tag, and use findObjectwithTag

#

store that into generador like you do already. Then call generador.GetComponent on the next line

#
private void Awake()
{
generador = GameObject.FindObjectWithTag("GeneradorLogicOrWhateveryouwanthere");
}

private void start()
{
generador.GetComponent<LogicaGenerador>();
}
#

lemme know if it doesnt work

hazy token
autumn tinsel
#

yes. do that. then go into unity and give that same tag to your gameobject

#

then in the start method call the generador.GetComponent

#

then show me your new script

hazy token
#

wait, do I have to replace this?

autumn tinsel
#

i will double check you did it all corrextly

#

yes

hazy token
#

ahh

autumn tinsel
#

your using findobjectby tag and then splitting what you had into 2 sepearte lines

#

one in awake

#

and one in start

#

you store it into the variable generador in awake. Then you get that component in start once everything has started

hazy token
#

ehhh

#

this?...

#

no, clearly not so

autumn tinsel
#

whats the error under it saying

#

the red squiggly

hazy token
#

Assets\Codigos\Dificultad.cs(13,21): error CS0029: Cannot implicitly convert type 'UnityEngine.GameObject[]' to 'LogicaGenerador'

autumn tinsel
#

yea instead of LogicaGenerador at the top make it GameObject

hazy token
#

or...

#

Sorry, I'm still having a hard time understanding things.

autumn tinsel
#

yupp change that LogicaGenerado to GameObject

#

You are searching for the GameObject

#

Then you search for the component

#

so that variable needs to be a GameObject

#

You are storing whatever GameObject it 'findsWithTag' back into generador.

#

so generador itself has to be a GameObject

#

make sense?

#

You can only put data into boxes of the same Type

#
GameObject generador;
hazy token
autumn tinsel
#

Try to take the s off of Objects on line 14

#

FindGameObjectWithTag

#

also what did you name your tag

#

tag is different than the name

#

of the GameObject

hazy token
autumn tinsel
#

GameObject.FindObjectWithTag("YourTagHere");

#

Did you give your gameobject a tag?

hazy token
#

nop

autumn tinsel
#

gotta do that...

hazy token
autumn tinsel
#

Put your mouse over the red squggly what does it say

#

???

hazy token
#

sorry

#

Assets\Codigos\Dificultad.cs(13,32): error CS0117: 'GameObject' does not contain a definition for 'FindObjectWithTag'

#

I am back