#I have objects that are entering

1 messages · Page 1 of 1 (latest)

mellow isle
forest dragon
#

ok

mellow isle
#

there is an enum of machines the object can enter and a list for some reason I dont know the purpose of

rose scaffold
#

@forest dragon can an object enter more than one machine?

#

uh oh, he's been . . . taken . . .

mellow isle
#

@forest dragon What is going on?
it's been almost 10 minutes, and Discord says you're Away
At least link the code before going afk

neon tulip
#

again

public class Enterable : MonoBehaviour
{
   public List<Places> AllowedPlaces = new();
}
#

Places is an enum that contains some places

#

It is in a seperate Places.cs file

#

Now attach the Enterable component

#

To your object which needs to enter something

#

Then select the places u want.it to be able to enter in the inspector

neon tulip
#

Now create another script that is attached to a gameobject with a trigger collider

#

And in its ontriggerenter function

forest dragon
#

here is my list of machines

neon tulip
#

Check if the entered object has the enterable component

#

If it does, check its list to see if it contains

forest dragon
#

here is my list of enterables in each gameobject

#

here is what I have on the transform

neon tulip
#

The place that corresponds to that gameobject.

forest dragon
#

code

mellow isle
neon tulip
#

Literally everything you need

#

i just said

forest dragon
forest dragon
forest dragon
neon tulip
rose scaffold
#

i'd use an enum with the Flags attribute so you can select all the places an object can enter. when an object attempts to enter a machine, just check if the value of the object's enum variable is contained in the value of the machine's enum variable . . .

forest dragon
#

wtf Im sorry Im genuinely trying to understand I just dont get the grammar

forest dragon
#
    enum Machines 
    { 
        heater, grabber, extruder, cutter, press 
    }
    public List<Machines> machines = new();```
neon tulip
#

how is that even remotely the same

forest dragon
#

machines are all the places, you want me to predefine all the places before hand no?

neon tulip
#
enum Machines 
{
  Heater, Grabber, Extruder, Cutter, Press
}
#

Put that in its own fole

#

File

#

Machines.cs

neon tulip
#

and add it to a gameobject

#

then select the allowed Machines in the inspector

#

now

forest dragon
#

is <Places> supposed to be the name of something

#

that I should replace or no

neon tulip
#

Sorry thst should be Machines

#

Not Places

#

Figure it out from there

#

Im done

#

Cya

forest dragon
#

cya

rose scaffold
#

okay, let's try this. make a separate/new script file and create (or copy) your MachineType enum into it. the filename should be the same as the enum . . .

#

the same exact way all of your filenames match the class name of your other scripts . . .

#

?

forest dragon
#

@rose scaffold ok did that, sorry was walking my dog on the mountain

rose scaffold
#

then create a variable with the enum type on the object — your MachineValues class — and the machine (they can enter) . . .