#Addressables help

1 messages Β· Page 2 of 1

royal grotto
#

for comparison

#

the problem really

#

is that

#

your builtin

#

seems to be pointing to the games folder

#

do this

sage pine
#

i clicked on view top level settings

royal grotto
#

basically on that oyu should put the same u put on LoadPath <custom>

sage pine
royal grotto
#

build the addressables

#

and before u actually put it in the game

#

send the catalog.json pls

sage pine
#

built

swift tinsel
#

now it's correct

royal grotto
#

EXACTILY WHAT I SAID MUNIX

royal grotto
#

why doesnt unity let us change the builtin settings more easy?

#

btw

#

well its not of much help for you now

swift tinsel
#

template needs that

royal grotto
#

but any new group you create now will have the right settings

sage pine
#

good to know

swift tinsel
#

because seriously wtf

royal grotto
sage pine
#

also have no idea how you would make a template that has everything ready to go for unity

royal grotto
#

tho i'll double check

royal grotto
#

yeah most unity files are readable, so you can just search for something and replace

swift tinsel
#

most of the stuff is set up in text files, and when you generate the project, you just replace placeholders

sage pine
#

i understand the dark sorcery you both use

#

its okay.

#

OMFG

royal grotto
#

πŸ™

sage pine
#

i have a box.

#

LUL

royal grotto
#

God is great

#

lmao

royal grotto
#

im not even religious

sage pine
#

hail satan!

royal grotto
#

either way im happy for you!

swift tinsel
#

all hail the box

swift tinsel
royal grotto
#

same workflow for the particle acelerator btw

sage pine
#

whats in the box?

#

candy...

#

i dont know what workflow means

#

but at least now, ill forget in 2 months how to do this

royal grotto
#

remember, same thing you put on the partName, you put on the addressables pair
and the addressables pair is always

  • partName.json
  • partName.prefab
sage pine
#

LUL i can color the box

#

that makes sense

#

and im gonna go through this post to make sure i write down the procedures of how to do this

#

maybe in 2 months munix has the template

royal grotto
#

i mean the template is not something that easy to do xD

swift tinsel
#

I sure hope it won't take that long lmao

sage pine
#

lol

swift tinsel
#

but right now I'm completely rewriting the current templates

#

so this will come after that

sage pine
#

well now i need to finish my linac modules

#

then figure out how i can upload them inidivudally

#

so theyre three separate parts

royal grotto
#

just make 3 separate prefabs

sage pine
#

no worries

#

thats what i was gonna do

royal grotto
#

withr 3 separate core part data

#

with 3 different partNames πŸ™

sage pine
#

but ive gotta look at my models and decide what is going where

royal grotto
#

thast what i meant by easy after the first setup

sage pine
#

yeah now that i have a template

#

if i never close unity

#

itll work

#

LUL

swift tinsel
#

it was painful but it was worth it munley

royal grotto
#

it would be funny if it wasnt the truth

#

either way cya!

swift tinsel
#

good night finally lmao

sage pine
#

night!

round lion
#

Minecraft textures amirite klueless

sage pine
#

@royal grotto Do I need to duplicate what I did with testpart with all of these or since they're the same part when they're assembled, can I place them together and use one collider for them?

sage pine
sage pine
#

first test with this lets see how it goes

royal grotto
#

Dont forget to tick the Convex box on it

sage pine
#

this is how i have it, it all goes to the testPart

#

so testPart will get smesh collider? or will that go with the individual parts?

#

using capsule colliders right now

round lion
#

why are you making 5 seperate collision boxes?

sage pine
#

I thought I had to

round lion
#

you don't have to lmao

sage pine
#

hm

round lion
#

just put one of the col's and then the other 2 game object thingys from the video(s), then just add a mesh collider and click on convex

sage pine
#

so i can remove the colliders from the connectors?

round lion
#

I mean yeah

#

you just need collider

sage pine
#

so one collider per part?

round lion
#

per part

#

yes

sage pine
#

and it makes it collidable

#

weird

round lion
#

it makes everything collidable

sage pine
#

makes sense but also weird

round lion
#

from said part

sage pine
#

and the collider should be a mesh collider?

round lion
#

yep

#

enable convex on it

sage pine
#

so what does that do now? it makes the entire part mesh collide

#

ohhh

round lion
#

this should be the structure

sage pine
#

so now it interacts with surfaces

round lion
#

dunno if it's needed

#

but It works for me

round lion
sage pine
#

oh weird

#

so the collider is a parent of all the little parts?

round lion
#

how munley

sage pine
#

dafuq is the box thing for?

round lion
#

it's just a random name for the mesh

sage pine
#

so what is in collision and what is in box?

round lion
#

okay 1 sec

sage pine
#

if box has a mesh, im confused now

round lion
#

this is for example another part

#

collision is just an empty gameobject

#

so is col_box_prim

sage pine
#

with no components?

round lion
#

yeah

#

and this is mesh

#

the "mesh" in mesh collider should be your .obj

#

for the part

sage pine
#

why the heck is collision even there if its just an empty game object?

round lion
#

don't ask me, I just used the tutorials from stick awhile back

sage pine
#

alright then lol

round lion
#

yeah it looks like it's working

sage pine
#

thank you! i had no idea, thats pretty dope

sage pine
#

@round lion @royal grotto when i export two parts, they just sink through the airfield?

royal grotto
#

the collider needs to be convex!

sage pine
#

they are

#

could it be an issue of the animation? since my animation isnt working properly, could that cause issues with the mesh?

#

also i removed srfAttach from the collector. could that be causing an issue?

round lion
#

are these meant to be 2 seperate parts in one? Why do you have 2 .json's? Also it may be your animation not being controlled (at all or properly)

#

wait no nvm

sage pine
#

two separate parts but they work together

#

ultimately ill have three parts

#

collector, waveguide, and electrongun

round lion
#

ah I see

#

well that could be a bit challenging

sage pine
round lion
sage pine
#

yup i removed animation as i dont need it right now

#

ive got the animations, but not using them as it just yeets stuff lol

round lion
#

yeah you need to somehow control em

sage pine
#

yup

#

and that will be user based etc and a bit more than i need to do right now

#

right now is just testing textures

#

glad my animations work and when i get to that point ill get them functioning properly

round lion
#

wait so did the collision fix itself or smth?

sage pine
#

not sure

#

im about to test

#

to see if the animation was causing the issue

round lion
#

honestly I need to sit down and see how to make them work properly too lol

but anyways, I doubt the animation would be the issue

#

oh I know what it might be

#

on an earlier picture you didn't set the Mesh collider's mesh

sage pine
#

itll be good to know how to animate properly as itll be nice. especially being able to have a "right click > deploy" option

round lion
#

the animation part in unity is easy, it's hard implementing it

sage pine
#

you right

#

hm

#

i tested it wasnt the animation so im looking at the mesh

#

so where it says Mesh None (Mesh) i need to set that?

round lion
#

YEP

#

aa caps lock

sage pine
round lion
#

but yeah you need to set it to the .obj of the part

#

I think

sage pine
#

hm

#

makes sense

round lion
# sage pine

find it in the project tab and then just drag it onto that

sage pine
#

will do

#

brb i appreciatg the help, ill let you know if it works

round lion
#

no problem lol

sage pine
#

worked

#

now they're coolidable

#

however you spell that

round lion
#

nice

sage pine
#

sort of

#

gotta tweak it but yeah it collides

round lion
#

that's good

sage pine
#

and the collider loses all texture when it loads into the game but in the vab it has texture

#

weird

round lion
#

I honestly got no idea

#

I have a similar bug

sage pine
sage pine
#

does not setting the CoM etc cause issues?

#

oh

#

when i make these parts, they have to use 0,0,0 (x,y,z) when i prefab them otherwise it makes it unbalanced

sage pine
#

those are the two gameobjects that have the meshes attached to them

#

in game, the collectorbase is off center by -6

#

which causes it to be off balance

#

so is my theory

royal grotto
#

KSP2 Unity Tools gives you the CoM preview

#

that should be at the same position as the center of your mesh

sage pine
#

so i need to move the com of that object

#

to line up properly

#

ahh

#

this makes sense

royal grotto
#

test it!

sage pine
#

rebuilding

#

i also need to make a paintmap that works properly. the one i made doesnt allow it to be transparent for some reason

#

but currently its all about...

#

metal. testing metallic textures

royal grotto
#

wait

sage pine
#

is the mesh messed up with its position?

royal grotto
#

your collision

sage pine
#

collision is completely blank

royal grotto
#

your colliders are in these 2?

#

oh ok

#

where are your colliders?

sage pine
#

yup its what worked and what yeetster showed me

royal grotto
sage pine
#

in the gameobject collector and waveguide

royal grotto
#

yeetster propapagating his wrong doings

sage pine
#

LUL

royal grotto
#

already told him the right way to do things but he just ignores me

sage pine
#

how should it be structured?

#

thegameObject
--part
--part
--------mesh

#

?

royal grotto
#

Basically something like this

partName (GameOject with partCoreData)
-model(Empty GameOject)
 -mesh(GameObject with Mesh Filter & MeshRenderer)
 -col(GameObject with MeshCollider)
#

the game needs that empty GameObject named model

#

also the Mesh Filter/Renderer should not be in the same Game Object as your collider

#

also the mesh and the collider should be a child of the "model" empty game object

sage pine
#

can you pin that?

royal grotto
#

sure

sage pine
#

be a good reference as i make parts

sage pine
#

i appreciate it ill rework this and test it and paste results

royal grotto
#

you can put the "col" as a child of the "mesh" if you want

#

also both the "mesh" and the "col" can be named whatever you want, i put it like that cuz thats how i name most of the times (if its only 1 mesh and 1 collider on the part)

sage pine
#

yeah its easy to name them mesh or col as it makes things uniform

#

and im all about uniformity so everyone is on the same page

#

makes it easier to debug stuff

royal grotto
#

as you should πŸ™

sage pine
#

so heres where i get confused

#

mesh is attached to one of the objects

royal grotto
#

thast no problem

sage pine
#

then col is attached to mesh as a child

royal grotto
#

wait so every Collector_ is a mesh filter and renderer?

sage pine
#

the collector_ is the componenets

#

all of those make up the "collector" part

royal grotto
#

they dont have colliders right?

sage pine
#

nope

royal grotto
#

great

#

now, select the col

sage pine
#

the Collector has the collider currently

royal grotto
#

does it show green lines?

sage pine
#

model is empty

#

when i click on the collector it shows a grid

royal grotto
#

let me get into unity so that i can show u what i mean a sec

sage pine
#

i appreciate it lux

royal grotto
#

notice the green lines?

sage pine
#

yes

royal grotto
#

thats the collider

#

you should have the same green lines

#

but of them being the shape of your part

#

from what i can see you have a triangle there in the back

sage pine
royal grotto
#

which doenst seem right

sage pine
#

yeah some random triangle thing

royal grotto
#

can you click on the col, and show me what components it has?

sage pine
#

i havent done anything with col yet

royal grotto
#

yeah makes sense

sage pine
#

collector has the collider in it right now

royal grotto
#

actually its one of its childs that has the collider

sage pine
#

oh

royal grotto
#

as you can see theres no Collider component there

sage pine
#

so collector is empty?

royal grotto
#

the collector has these 3 components

sage pine
#

i misunderstod what the collidr was

#

i thought core part data was the collider

royal grotto
#

nono xD thats all the data of your part

sage pine
#

but mesh is the collider

royal grotto
#

ok makes sense

#

well its off center as you can see

sage pine
royal grotto
#

exactly thats what i was gonna say

#

tho

#

your mesh seems wrong then

#

for such a complex part

#

i'd advise you make a new mesh in blender

#

to put as a collider

#

basically just a simple mesh that you feel like will give u the collider you want

#

if you want, for now it can be just a cyllinder

#

that encapsulates all of the other meshes

sage pine
#

its the same mesh i used before

#

but i think mesh collider is causing issues

royal grotto
#

the mesh collider simply gets the mesh you feed it and and "shows it as green lines"

#

what does it look like w/o convex?

sage pine
#

oh weird

#

each mesh is way different

royal grotto
#

yup

#

tho, how does it look w/o convex?

#

a convex mesh is a mesh with a max of 256 vertices

sage pine
#

normal

#

thats weird

royal grotto
#

yeah

sage pine
#

no convex and it looks like its supposed to

royal grotto
#

but you cant really use non convex meshes in ksp

#

it would generate a LOT of lag

sage pine
#

lol

royal grotto
#

just imagine you're a collision program trying to detect either or not you're colliding with that thing

#

you'd have to check every step of the way

#

when you have a convex mesh you're either colliding or not, theres no inbetween

sage pine
#

yeah thats a lot to maths

royal grotto
#

on your mesh if you're on the center ur not colliding, but a bit to the side you are, but a bit more to the side you arent

#

etc etc

#

either way, unity tries to make your mesh convex

#

but due to the complexity it cant

#

thus you needing to make a mesh on blender for colliding

sage pine
#

this is just an empty cylinder?

#

thats what confuses me its the same thing as the waveguide tube

royal grotto
#

now try to turn that empty cyllinder into only 256 vertices xD

sage pine
#

cries

royal grotto
#

The convex option is like stretching rubber bands between the outer-most vertices. Just like Tiimmy said, Unity makes a more efficient mesh for objects like this rock example. You could also think of it as gift-wrapping your mesh. Irrespective of how helpful it is, primitives are nearly always going to be more efficient.

#

Basically the convex check mark will make a collider around your mesh without any 'indented' areas.

#

there's ways to make your mesh hollow tho dw

#

but you'll need a bit more blender magic for that

sage pine
#

thats what is weird to me

royal grotto
sage pine
#

i build this cylinder the same way i built the other cylinder

royal grotto
#

the other has a cap in it doesnt it?

sage pine
#

nope

#

they're both hollow

royal grotto
#

either way unity is having trouble transforming that into only 255 triangles

sage pine
#

i have an idea as to why

royal grotto
#

maybe do to the complexity of the mesh

sage pine
#

its how its shaded

#

when i have it as...

royal grotto
#

oh thats no problem

sage pine
#

shaded

#

it makes it complicated

royal grotto
#

nono thats no problem

sage pine
#

when its just auto shaded its just like the other one

royal grotto
#

thats normals

sage pine
#

oh

royal grotto
#

not the actual mesh

#

that doesnt affect your mesh per say

#

just how the triangles are oriented

#

tho if you want to make your mesh hollow

#

you'll have to make the walls in 255 triangles

sage pine
#

this makes zero sense. literally the cylinder is a copy of the waveguide tube

royal grotto
#

you can divide that into various sections

sage pine
#

they're literally the same part

#

one of them i can have normal physics on, and the other one goes haywire

royal grotto
#

you can just use the waveform mesh then

sage pine
#

alright reworked those

#

what goes in col? also it has simplified the mesh so its not a billion vertices.

royal grotto
#

great

#

on the coll

#

you put a Mesh Collider

#

and set that simplified mesh to the mesh section

sage pine
#

so mesh gets a mesh collider AND col gets a mesh collider?

royal grotto
#

no, the mesh should not have a mesh collider

#

only the col

sage pine
#

k

#

so the col';s now have mesh colliders and theyre using convex's

#

do i need to set the mesh to a gameobject?

royal grotto
#

well

#

the simplified mesh no

#

unless you want to use it for something

#

as you can see now i thas the green lines

sage pine
#
col - Mesh Collider 
          Check - Convex
          Cooking Options: Mixed
          Material - None
          Mesh: Collector_Tube```
royal grotto
#

yeah

#

thats right

sage pine
#

then theres someting called simpilified mesh that goes into mesh?

royal grotto
#

tho you dont need to worry about the 2 in the middle

#

Yeah, you put the simplified mesh on the Mesh:

sage pine
#

ohh

#

i see

#

nope. i dont see.

royal grotto
#

yes, you put the simplified mesh there

#

tho

sage pine
#

what do you mean by simplified mesh. is it something i create, it should be made, or is it what ive already go tselected?

royal grotto
#

oh sorry that was your question xD

#

yes the simplified mesh you create in blender

sage pine
#

okay

royal grotto
#

just just a mesh that encapsulates your whole part

sage pine
#

so it wont be called simplified mesh, itll be called whatever i called it

royal grotto
#

that will be the mesh that the game will use for colliding with things

#

yes whataver you wanna call it

sage pine
#

okay i understand now haha

#

i was like "i dont see simplified mesh"

royal grotto
#

πŸ™

sage pine
#

that fixed it, but ive gotta simplify the other parts to the collider

#

thats why the graphical glitch happened

royal grotto
#

@round lion do things right

sage pine
#

has to do with the colliders

royal grotto
#

meshes are just meshes, they have no collider

#

meshes quite literally just "draw themselfs to the camera"

sage pine
#

yup

#

i undersatnd what they are, i just needed to understand the proper way to do it in unity

#

so you've explained it very well. i appreicate it. im sure ill have more questions down the road lol

royal grotto
#

feel free to ask them!

sage pine
#

ah

#

any guide on animating things properly

#

ive got my animations

#

i just dont know how to use them properly because when i use them, the triggers arent set up etc

royal grotto
#

1st thing would be to normalize your mesh size and position

round lion
royal grotto
#

ctrl+a on unity

royal grotto
#

sorry @sage pine ctrl+a on Blender

#

THO careful

sage pine
#

do i need multiple mesh colliders for these parts? ie the ones in black

royal grotto
round lion
royal grotto
#

then no parts working for you MisatoPray

sage pine
#

ive already got the animations in unity from blender

royal grotto
#

game rules (literally)

royal grotto
#

honestly i do my animations on Unity

#

but theres a way to import them correctly

sage pine
royal grotto
#

i dont know if i can give you the proper help on that

#

oh wait

sage pine
#

animations are working properly that ive imported, i just dont know how to add them to the object

royal grotto
#

well its easy

#

add a Animation Controller

#

to the model game object i believe

sage pine
#

over here right? the animation tab on the object

royal grotto
#

wait wait

#

select the mesh gameobject

sage pine
#

mesh is attached to collector_tube which is not what i want to animate

#

the animation will be attached to the magnets (pos and neg)

royal grotto
#

then add a Animator to the part you want to animate

#

or better

sage pine
#

makes sense

royal grotto
#

an Animation Clip

sage pine
#

any idea what trigger vfx animation script does?

royal grotto
#

havent played with that yet

sage pine
#

i figure its the script that allows you to do exactly what it says

royal grotto
#

its from KSP not from unity so yeah

sage pine
#

ill mess with it later

royal grotto
#

well, should do what it says but we have to test that

sage pine
sage pine
#

wejll when i add "Animator"

#

and i assume i add different layers and those control which animation happens?

#

I think this will just make the animation loop

royal grotto
#

should be only 1 layer

#

you control the animation with

sage pine
#

ohh

royal grotto
#

the paramenters

sage pine
#

and then using the parameters changes how it animates etc

royal grotto
#

yup

#

in code you'll do something like

sage pine
#

makes sense

royal grotto
#

Animator.SetBool("parameterName", false);

#

or true

sage pine
#

ah

#

so thats how youll program it for user interaction

#

for it to do the animation

royal grotto
#

kinda yeah

sage pine
#

cause right now, since it has no trigger, its just going to go forever

#

lol

royal grotto
#

for your case you probably can use the game's provided ways

sage pine
#

yeah the idea is to make things deployable

#

since its science, i want it to be able to right click and have options for them to do the science

#

and animations attached to what they click

#

so they click "vaccuum seal particle accelerator"

#

and it does an animation

royal grotto
#

idk how science will work

sage pine
#

but thats a little bit away

royal grotto
#

so we'll have to wait on that

sage pine
#

yeah thats also why i havent tried tdo do anything with it yet

royal grotto
#

but you can make it just like solar panels and "Deploy"

#

for now

sage pine
#

that makes sense

#

obviously hvaent spent much time with the animations but thats down the road. at least i understand how to modify it and such

royal grotto
#

seems to be working tho! :D

sage pine
#

yeah it works but more to do to make it function better

#

ive gotta rework the animations in blender

#

and then figure out how to code the solar panels and deploy thing

#

unless you already have some script that i can use as a base?

royal grotto
#

thats easy (i think)

#

you dont need to do any scripting

#

its all done with Modules

sage pine
#

thats convenient

#

but i will have scripting

royal grotto
#

thats the whole concept behind modules

sage pine
#

ill have a GUI that looks like a computer screen

royal grotto
#

you have generic modules for what you need

sage pine
#

and lets the player use the GUI to modify behavior of the particle accelerator

#

buitttt again thats a good bit down the road

royal grotto
#

^

sage pine
#

today its about getting textures right

sage pine
#

ah

#

i need my textures in my blender file before i import them otherwise they don't work in game properly

#

but i did get this right

#

how they connect looks cool

sage pine
#

FYI: it's not a bug as to why it shows up black. If you don't UV unwrap your parts, the textures will show up black in game

royal grotto
#

yeah its actually just

#

that your mesh is all on 1 place of the Texture

sage pine
#

hm

royal grotto
#

if that 1 place is blue the texture will be blue

sage pine
#

hm

sage pine
#

@midnight torrent starting from here down is how lux help me get the gizmo's working as well as getting the addressables to work properly

midnight torrent
#

alr

sage pine
#

this is super important that you rename these to not be the full path. it will default them to being the full path. shorten it to whatever you've named your gameobject and your json

midnight torrent
#

where are they?

#

I GOT IT

sage pine
#

nice!

#

this thread is basically that tutorial plus more only problem is you have to search through it to find the fixes

#

lux has pinned some important stuff and as i remmeber things ill ahve him pin more

sage pine
#

@royal grotto so yeah ive got a few more things to tweak with basic textures, gotta make a paint map, and finish the electrongun model

#

but wanted to dabble with vfx a bit today

royal grotto
#

Then i recommend particle system as its what the game uses

#

You can layer them

sage pine
#

good to know

#

so a lot of experimenting should result in something useful

#

am i able to use this

royal grotto
#

Like 4/5 layers of particle systems isnt a bad idea

sage pine
royal grotto
#

Heh sure

sage pine
#

that was my plan was layering the laser in 5 layers

#

i was using line renderer and trail renderer to experiment with

royal grotto
#

It wont look great in ksp cuz the unitys line render aint the best but for now

sage pine
#

oh

royal grotto
#

That line render quite literally

#

Draws just a line

sage pine
#

yup

royal grotto
#

With no effects nothing

sage pine
#

dont mind me

#

LUL

#

im assuming this will work just like an engine

#

because the engine has a plume

#

but instead of it being plume for an engine, its just a laser beam

#

that will have heat etc

#

does your second video cover that part of the engine build?

#

used the same structure for the last part - the electrongun

#

but as this is vfx, does it go with the part its making a vfx for? or does it go separate?

sage pine
#

basically just shot a roll of toilet paper out of this thing

royal grotto
#

Lmao yeah thats what i mean for line renderer isnt the best

#

Unfortunately im the only one working on tools fo ksp2 atm so πŸ˜”πŸ˜”πŸ˜”

sage pine
#

this is particle system

royal grotto
#

GamePlay wise i mean

royal grotto
# sage pine

Oh god wtf the particle system also does that β€œrotate” thingie

sage pine
#

trying to figure out how to let it be a random seed but to also keep it within x,y,z spacing

royal grotto
sage pine
#

yeah

#

its epic

#

wait one

#

thats only one layer

#

there we go starting to hone this thing in and make particles

#

so each particle can create another particle lol

sage pine
#

particles go correct direction in unity (x axis) but in game they travel on the -z axis

#

is there something im missing with setting origins of particles up correctly?

royal grotto
#

parts in game are oriented upwards

#

think that the game is made for rockets

#

so you orient your parts as if they were part of a rocket

#

easy fix is to just rotate your particles

#

the right fix is to make your part be oriented up

sage pine
#

the part is oriented up πŸ˜‰

royal grotto
#

then im lost MisatoPray

sage pine
#

@royal grotto ```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ParticleTrigger : MonoBehaviour
{
public ParticleSystem particleSystem;
public Light[] lights;
public AudioSource audioSource;

private void Start()
{
    // Perform any initialization or setup here
}

private void OnTriggerEnter(Collider other)
{
    if (other.CompareTag("Player"))
    {
        particleSystem.Play();

        foreach (Light light in lights)
        {
            light.enabled = true;
        }

        if (audioSource != null)
        {
            audioSource.Play();
        }
    }
}

}

#

this is a script I was working on to add a trigger to the particles. is this the correct way to do it or is there another way to do this properly?

#
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

[ExecuteInEditMode]
public class TriggerScript : MonoBehaviour
{
    ParticleSystem ps;

    // these lists are used to contain the particles which match
    // the trigger conditions each frame.
    List<ParticleSystem.Particle> enter = new List<ParticleSystem.Particle>();
    List<ParticleSystem.Particle> exit = new List<ParticleSystem.Particle>();

    void OnEnable()
    {
        ps = GetComponent<ParticleSystem>();
    }

    void OnParticleTrigger()
    {
        // get the particles which matched the trigger conditions this frame
        int numEnter = ps.GetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter);
        int numExit = ps.GetTriggerParticles(ParticleSystemTriggerEventType.Exit, exit);

        // iterate through the particles which entered the trigger and make them red
        for (int i = 0; i < numEnter; i++)
        {
            ParticleSystem.Particle p = enter[i];
            p.startColor = new Color32(255, 0, 0, 255);
            enter[i] = p;
        }

        // iterate through the particles which exited the trigger and make them green
        for (int i = 0; i < numExit; i++)
        {
            ParticleSystem.Particle p = exit[i];
            p.startColor = new Color32(0, 255, 0, 255);
            exit[i] = p;
        }

        // re-assign the modified particles back into the particle system
        ps.SetTriggerParticles(ParticleSystemTriggerEventType.Enter, enter);
        ps.SetTriggerParticles(ParticleSystemTriggerEventType.Exit, exit);
    }
}
``` this is the example from unity documentation
royal grotto