#AI Manager finder

1 messages · Page 1 of 1 (latest)

pearl flower
#

Conversation continues here.

broken cape
#

yea

#

Like somewhere in the scene itself, in the game itself, no, its a empty object, it doesnt need to be in a specific spot somewhere

pearl flower
#

So then you're trying to display a message if the script cannot be found in the scene?

#

Anywhere in the scene yes

broken cape
#

but the box doesn't fucking appear

#

doesn't that mean that the ai manager is found?

#

because the box doesn't appear?

pearl flower
#

No no hang on

#

I'm talking about the AI manager script here

#

Not the animatronic thing

#

So then you're trying to display a message if the AI Manager script cannot be found in the scene?

broken cape
#

for the nodes yes

#

"Scene must have an AI Manager to populate nodes."

pearl flower
#

Yes, that would be a yes to my question

#

So you don't want to use FindObjectsOfTypeAll because it searches in your scene, and in your project files

broken cape
#

the nodes are these

#

if you wondered

pearl flower
#

You want to use FindObjectsOfType

#

That, will only check in the scene

broken cape
#

let me put that

#

but I still have a feeling that I should follow my theory

#

that

#

box not appear, AI Manager is found
box appear, AI Manager not found

pearl flower
#

Yes, that is what I'm also following

#

You're just using the wrong code for it

broken cape
#

no erros

#

errors

pearl flower
#

The line is commented lol

#

Remove the comment mark // at the beginning of the line

#

You will get an error

broken cape
#

BRO I LITERALLY CONTACTED MY TIC TEACHER TOO

#

AND HE TOLD ME TOO

#

USE THE //

#

fuck you mr. johnson

pearl flower
#

That just disables your code, you didn't understand your teacher correctly

broken cape
pearl flower
#

There we go, the errors I expected

#

First one, remove the AIManager[] aiManager = null; because it's not supposed to be there anymore

broken cape
#

I don't think the code is wrong, I think it's just old

pearl flower
#

It is wrong

broken cape
#

bro I knew a guy who used the exact same code that I use before i deleted the // and everything worked for him

pearl flower
#

Then, it's Object.FindObjectsOfType<AIManager>(), not Resources.FindObjectsOfType

#

And that's pretty much it

broken cape
#

brother

#

there is no

#

ohhhhh

#

im stupid nbm

#

alright

#

and now?

pearl flower
#

That's it

broken cape
#

If I tell you sum you wouldn't believe me

#

would you believe me?

pearl flower
#

If you have one or more AI Managers in the scene then the message will not show

#

Else, it will show

broken cape
#

no

#

there isn't no

#

there is the AI_Manager object and the AIManager script

#

which is on the object AND in the Assets/Scripts folder

pearl flower
#

There's an AI Manager object yes, it's detecting that

broken cape
#

oh shit

#

but I need the AI_Manager doe

pearl flower
#

The function does not care about the Assets

broken cape
pearl flower
#

Yes, try deleting that and come back to your Animatronic script

#

You'll see that there is the box now

broken cape
#

the ai_manager object?

#

😭

pearl flower
#

Well yeah that's literally what your code is checking!

#

Do you even know what your own code does?

broken cape
#

I deleted the object

#

still no helpbox

pearl flower
#

Then it's debugging time

#

Log the array's length before the if, in Animatronic's editor script

broken cape
#

Eazy-E

#

like this?

#

or you mean these?

pearl flower
broken cape
#

?

pearl flower
#

You didn't change anything

broken cape
#

nah it should be above

pearl flower
#

Debug.Log($"Array length is: {aiManager.Length}");

broken cape
pearl flower
#

I'm really starting to doubt your C# skills here

broken cape
#

doubt them idc

pearl flower
#

You should not be doing editor scripts if you don't know how to debug

#

Anyway

pearl flower
pearl flower
#

Will print the array length along with a recognizable message

broken cape
#

these are bugging me off

pearl flower
#

Then... remove them?

broken cape
#

Debug.Log("Camera " + i.ToString() + ": " + cameraTimeBetweenViews[i].ToString());
it has + i.ToString() + ": " + cameraTimeBetweenViews[i].ToString its bugging me off like

#

its confusing me

#

i need to delete it whole but im scared sum not gon work

#

BUT NAH

#

it in the debug log ()

#

fuck it

pearl flower
#

Remove

#

Them

#

It's not hard

#

Or you know, comment the line it's on

pearl flower
#

Then your editor code is not getting executed

#

¯_(ツ)_/¯

broken cape
#

bro what

pearl flower
#

Not sure why you launched the game

#

No need to launch the game to test editor code

broken cape
#

nah but these are good I never got these before cuz of the camera logs

pearl flower
#

That's the point of editor code, it runs in the editor

#

You'll have to select the object the Animatronic script is on though, for the editor code to run

#

Because you've put the code in OnInspectorGUI, which runs when the Inspector of the Animatronic script gets drawn

broken cape
#

brother

#

im trying to fix the other issue rn

pearl flower
#

Later

#

It does not interfere with the current issue

broken cape
#

it interferes with the fucking game doe

pearl flower
#

Bro

#

Do you even read what I'm writing

#

You do not need to run the game in order to debug an editor script

broken cape
#

BROTHER, YOU DON'T SEE THE TIMES THE ERRORS ARE SENT?! MY TIMEMANAGER/GAMEMANAGE WITH THE "ANIMATRONIC" WORKS

pearl flower
#

I give up

#

Good luck with your issue

broken cape
#

fuck off bro

#

like actually

#

my shit went BONKERS

#

like

#

badonkadong

#

style

#

like

#

WEEEEEEEEEEEEEE

#

boom

pearl flower
#

Yes, an error on line 58 of game manager

broken cape
#

OH REALLY?

#

I did not know that

#

thank you

#

if (gameTime >= transitionTimes[currentTransition])

pearl flower
#

Which, is probably due to the fact that you deleted the AI_Manager object earlier

pearl flower
#

Then paste it back?

#

Or add it back

placid escarp
broken cape
#

im just trying to fix this one

#

it confirms the little 3 idiots want to "move" but they cant

pearl flower
#

One thing at a time please

placid escarp
pearl flower
#

Ah we're in for a world of hurt

pearl flower
#

Probably due to the fact that the AI Manager was emoved, too

#

Yes!

placid escarp
#

Also what happened to the out of range

pearl flower
#

Posting with the line numbers can help

broken cape
placid escarp
pearl flower
#

Yes! So add that AI Manager back to the scene

pearl flower
#

Code says otherwise

placid escarp
#

Where do you set AIManager.Instance

broken cape
#

in the fokin AIManager script, it had to get the instance from somewhere

pearl flower
#

It worked before you deleted the object, so either you didn't add it back, or you didn't attach an AI Manager to the object

broken cape
#

can't get the instance from thin air

broken cape
pearl flower
#

That's declaring it

#

Where do you set it

#

ie. put a value into it

placid escarp
broken cape
#

uhhhhhhh

pearl flower
#

It's not complicated really

#

Where do you put a value into it?

placid escarp
#

You have to listen to the things the code is telling you. It says the value is null, so go check where you set it

broken cape
#

void Awake ()
{
Instance = this;
}

#

AIManager.cs

placid escarp
knotty pondBOT
#
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.

broken cape
#

should I put something specific?

#

like

#

SPR2 here put a $ in ""

placid escarp
#

At this point anything

placid escarp
broken cape
#

I got this when I started the game

pearl flower
#

If that's what you put in Awake, that means it has run

#

Then the other script that fails on line 62 runs before AIManager, which would be the cause of the exception

broken cape
#

NO ERROR

#

HAHAAAAAAAAAAAAAAAAA

#

WAIT WIAT

#

SECOND TIME

#

HAHA! IT WORKS!

pearl flower
#

How did you fix it?

broken cape
#

bruv

broken cape
placid escarp
#

My guess is by putting the instance in the scene

pearl flower
#

Yeah most likely

broken cape
#

HAHA

#

5TIMES NO ERRORS

#

HAHAHAAAAAA

#

THEY SAID I COULDN'T DO IT

#

BUT LOOK AT ME NOW

#

HAHAAAAAAAA

#

🦅 IM THE BIGGEST BIRD IM THE BIGGEST BIRD 🦅

pearl flower
#

No you just fiddled until it worked

elder harness
#

@broken cape Spam warnings include threads as well. And you are out of warnings.

pearl flower
#

Do us all a favor and learn how Unity works, and how scripting works

broken cape
#

i wouldnt call that spam, i would call that celebration

elder harness
#

I would call it a ban if you continue

broken cape
#

no i wont

pearl flower
#

It's not magic at all, computers just follow your instructions

#

If you tell bad things, it does the bad things

broken cape
#

But fog, you do know that i'm the biggest bird, right? Normal question no spam no nun

pearl flower
#

This is off-topic, you're running out of warnings here

broken cape
#

alright brother brother kifflom SPR2, what was the other issue that I had?

pearl flower
#

The editor code, not showing the warning box

broken cape
#

oh yeah

#

and that

pearl flower
#

Ah yeah the other error

broken cape
#

I have 2 sides, works and error

#

58?

pearl flower
#

You're accessing an array with an index that is too low or too high

#

Yes, line 58

broken cape
#

the index is random, it can be between 0 and 7

#

its kinda RNG

pearl flower
#

Then the array has less than 7 elements in it

broken cape
#

!code

knotty pondBOT
#
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.

broken cape
#
if (gameTime >= transitionTimes[currentTransition])
        {
            currentTransition++;
            AIManager.Instance.TransitionOccured();
        }
#

this is everything that has sum to do with 58

pearl flower
#

currentTransition was too low or too high.

#

Debug.Log its value

#

Before the if statement

broken cape
pearl flower
#

That's the initial value, which is valid

broken cape
#

VALID 🦅

placid escarp
#

Log the value before the error

#

see what number it gets that gives you the problem

broken cape
#

I will right now

placid escarp
#

It's either negative or above 6

#

Or the list changes

pearl flower
#

Definitely above 6 since they just increment it in that if statement

#

Unconditionally it seems

broken cape
#

it just spams this like w the cameras

pearl flower
#

Because you haven't told it to?

placid escarp
#

or did you log text

broken cape
#

text brother

placid escarp
#

it's only going to print what you tell it to print; it's not magic

pearl flower
#

inb4 Log("What seems to be the problem?")

placid escarp
#

Log the value, before the error

#

This is not the value

#

this is a string of text

broken cape
#

inb4 what this

pearl flower
#

Nothing important

#

Log the value

broken cape
#

any number?

pearl flower
#

No for god's sake

#

currentTransition

#

That's the source of the error

#

Logically you would like to see its value

placid escarp
#

Log

#

The

#

Value

#

As I said the first time

pearl flower
#

Told you we were in for a wild ride :)

broken cape
#

nah nah

#

so far its 0

pearl flower
#

Look at the last log, before the error

broken cape
#

Hope I did this correctly

pearl flower
#

Yes this is good

placid escarp
broken cape
#

it switched to 1

broken cape
placid escarp
#

So go do that

broken cape
#

it IS doing that

#

now its 3

#

in the log

#

s

pearl flower
#

Wait until you get the error

placid escarp
#

Just tell us when it errors

#

whatever value it printed before then

broken cape
#

sooo

#

hows life?

#

this takes far too long

placid escarp
#

A little worse since I joined this thread

broken cape
#

so far its 5

pearl flower
#

It can't be that long

broken cape
#

HOL

#

HOL

pearl flower
#

The transition times are less than 5 seconds each

#

Should have taken less than 30 in total

broken cape
#

number 6
error
number 6
error

pearl flower
#

Yeah, the array is length 6, so you can only access indices 0 to 5

#

Accessing index 6 throws that error

placid escarp
broken cape
placid escarp
#

So that would be the problem

#

You are increasing your currentTransition without regard to the size of the list

#

Don't increase it if it's at the end

broken cape
#

do you want to the code? I'm not increasing anything manually

pearl flower
#

haha wrong

#

currentTransition++; does increase its value by 1

#

You have that in the code

broken cape
#

i can't objection that claim now

#

because it is true

#

okay so.... +-? +? --? -+? -?

pearl flower
#

++: add 1
--: remove 1

#

Only these two exist

broken cape
#

hmmmmmmmm

#

++ isn't good in this context

#

but i dont think -- is either

pearl flower
#

It is perfectly good in this context

broken cape
#

adding currentTransition--;?

pearl flower
#

No

#

Having currentTransition++;

#

If you don't have that then the transitions will never be made

broken cape
#

thats what im saying

#

I can't delete it

pearl flower
#

So do what Digiholic said

pearl flower
#

Don't increase it if it's at the end

broken cape
#

so i cant remove it

#

its will break everything

#

I also should NOT increase it if its at the end

#

I can't just move it else where in the script

pearl flower
#

Just, check that you're at the end before accessing the array

#

You know how to do that right? You've done at least two if statements, from what I can see looking at the past 2 hours of conversation

broken cape
#

hmmmmmm

#

i dont know what I've done here

#

if (currentTransition++ = true)
{
currentTransition++ = !currentTransition++;

}

#

if im trying to read it out loud

#

it makes sense

#

but

#

game making wise

#

i dont think it does

pearl flower
#

Even C# wise

#

You need to do:

Is it less than 6?

#

And that's pretty much it

broken cape
#

WAIT

pearl flower
#

If it is, you can add one. Else, don't do anything

broken cape
#

if (currentTransition++ < 6 )
{
currentTransition++ = !currentTransition++;

}

#

hmmmmmm

#

still not good

#

c# wise

pearl flower
#

Clearly not

#

I would suggest taking basic scripting courses at this point

#

Because you're just guessing, you have been guessing this entire conversation

broken cape
#

its not my fault that I can't I make a script using my own words

#

do you know how much EASIER would that be?

pearl flower
#

It pretty much is your fault, sorry to say but truth hurts

broken cape
#

i basically need to tell it

brother, if its less than 6 do not increase it no mo

pearl flower
#

Knowing how to translate words into code is the core of programming

broken cape
#

give me translator pls

pearl flower
#

No, I won't give you code that just works

broken cape
#

i never said code

#

i NEVER said give me code

#

You're now putting words in my mouth

pearl flower
#

Then what do you want me to say

broken cape
#

i have no idea

pearl flower
#

That's the closest I can get without giving you the code

#

If it's less than 6, you can add one. Else, don't do anything

#

Can't get clearer than this

broken cape
#

so if the currentTransition < 6

#

let me COOK

#

if currentTransition < 6

#

{

#

bROOOOOO

pearl flower
#

Getting there...

broken cape
#

increasing by 1

placid escarp
#

You increase it three times in that alone

broken cape
#

huh?

#

WHERE THE 3 COME FROM? 💀

pearl flower
#

Each highlighted place adds one

#

You have three places

#

Adds 3

broken cape
#

OHHHHH

placid escarp
#
if (currentTransition++ < 6 )
{
  currentTransition++ = !currentTransition++; 

}

Means this:

  1. Check if currentTransition is less than 6
  2. Add one to currentTransition
  3. Check if currentTransition is equal to the opposite of currentTransition (which also makes no sense by the way)
  4. Add one to the currentTransition
  5. Add one to the currentTransition
#

This entire snippet is nonsense, but it also demonstrates a lack of understanding of ++ or variables in general

broken cape
#
if (currentTransition < 6)
{
   add +1
   else = -1
}
#

now let me cook w this one

#

more

placid escarp
pearl flower
#

aww

broken cape
#

let me cook more

placid escarp
#

This is programming gibberish. I suggest doing the Intro to C# course linked in the pins and learn the syntax of dealing with numbers and if statements

broken cape
#

no, not yet, let me cook

#

so "add" is a command or sum

#

no

#

it STILL doesnt look right

#
if (currentTransition < 6)
{
  you can add 1
  else = none
}
#

hmmmmmmmmm

pearl flower
#

How do you add one to a variable?

#

You know this, you tried to do it three times

broken cape
#

if (currentTransition < 6)
{
currentTransition = -1;
}

placid escarp
#

what

pearl flower
#

Nope, still not

placid escarp
#

It would probably be a good idea to think instead of making random guesses until we tell you it's right like Patrick opening the pickle jar

broken cape
#

BRO I ALREADY KNOW HOW TO PUT IT IN WORDS

#

JUST NOT IN THE CORRECT LANGUAGE

pearl flower
#

(That sets the value to -1, it does not add one, it does not remove one either)

placid escarp
#

in words

#

what does this do

broken cape
#

nothing basically

pearl flower
#

No, tell us

#

What does it do

placid escarp
#

explain what this does

broken cape
#

so if its less than 6, its -1 which doesn't make ANY sense

placid escarp
#

you seem to know what it means

broken cape
#

anyone can read WORDS

placid escarp
#

you just read it to me and translated it to words

broken cape
#

code is eating my life away

#

thats what it is

pearl flower
#

Because you never bothered to learn properly?

placid escarp
#

= is a word. It means "Set this variable to"

#

-1 is a word. It means "negative 1"

#

These are all "words" in programming

broken cape
#

I learned - numbers half of the math lessons I did my whole life

placid escarp
#

currentTransition is a programming word that means "The number currently stored in the box labeled currentTransition I keep on the shelf"

#

So, currentTransition = -1 means "The number currently stored in the box labeld currentTransition I keep on the shelf, set that value to, -1"

broken cape
#

do i have to use int's?

#

I hate ints

#

even tho I used them

placid escarp
broken cape
#

i HATE ints

placid escarp
#

What would you want to use instead

broken cape
#

normal words and not this = that ++; to --; and Random.IEnumerator

placid escarp
#

"One" is not a normal word?

#

You just told me off for explaining that -1 means "Negative one" and now you're saying that numbers are too hard?

broken cape
#

I never said that

placid escarp
#

It is basically the absolute simplest kind of numbers imaginable

#

no decimal points

#

relatively small selection of possible values

#

only thing that's simpler is a uint because those can't be negative

broken cape
#

so the number is 6

placid escarp
#

So what do you think would make this easier instead of using ints

broken cape
#

i basically need to tell it to to not increase it after 6

#

i know the if loop

#

its

#

if ( currentTransition < 6)

#

throw it out the window, save it for later

#

and NOW i have to tell it to

#

increase by 1 if necessary but if not, dont do it

placid escarp
#

So, you have a line for "If currentTransition is less than 6". What do you want to happen if currentTransition is less than 6?

broken cape
#

make it increase by 1 if necessary

placid escarp
broken cape
#

++

#

right?

placid escarp
#

So then what's the problem?

#

You know what you want to do, and you know when you want to do it

#

so just moosh those two thoughts together

broken cape
#

if ( currentTransition < 6)
{
currentTransition++
}

placid escarp
#

Congratulations

broken cape
#

NO

#

WAS THAT IT?!

placid escarp
#

Yes

broken cape
#

NAH

#

I DONT BELIEVE YOU

placid escarp
#

At no point in your guessing did you ever have that

pearl flower
#

That is indeed correct

broken cape
#

I DONT BELIEVE NO ONE

#

so I just make a new for loop?

pearl flower
#

No just place that if where you have the original currentTransition++

placid escarp
#

So you will increase it twice

broken cape
#

I should replace this

#

with this?

pearl flower
#

Not all of it

#

You of course need to keep the condition you already have

placid escarp
pearl flower
#

And that TransitionOccured thing

broken cape
#
if (gameTime >= transitionTimes[currentTransition], currentTransition < 6)
{
    currentTransition++
    AIManager.Instance.TransitionOccured();
}
#

?

placid escarp
#

That's not how you combine if statements

pearl flower
#

That's a possibility though

#

The syntax is not correct, but it would also work

placid escarp
#

Yes, you could combine it into one if statement. But you should look up how to do that

pearl flower
#

It might be better to go the simple way here

#

You can put one if into another, you know that?

#
if (a)
{
    if (b)
    {
    }
}
broken cape
#

oh yeaah

#

the thing that makes you go boogy 🍔

#
if (gameTime >= transitionTimes[currentTransition])
{   
    
    AIManager.Instance.TransitionOccured();
    
    if( currentTransition < 6 )
    {
      currentTransition++;
    }
 
}
placid escarp
#

Why are you increasing it by two

broken cape
#

now?

pearl flower
#

Have you tried it? Because that looks good now

broken cape
#

i fell asleep lmao

broken cape
#

Well there aren't no error messages now, but I keep getting the Transition Occured message

#

@placid escarp

#

but no errors

#

no errors and its over 6am in the game

broken cape
#

screw the box

#

so far every issue i had besides the helpbox has been fixed

#

thank you guys