• Spawning particle effects inside a model?
    12 replies, posted
I need to spawn particle effects inside the model, I have only managed to spawn it inside the OBB of the model without any rotation, which really only works for squares with 0,0,0 angles. How would I spawn the particles inside the actual model as in the legs of a chair and not in the empty space around the legs etc.? Only way I could think of would be spawning the particles in between OBBMins and OBBMaxs and making a trace right where the particle wants to spawn and if the trace instantly hits the entity, it spawns, else it will try another position. I believe this would be a very unoptimized solution of I wanted to spawn 50 particles?
You will have to manually set the particles position depending on the model position. You can use GetPos along with GetUp, GetRight and GetForward on the entity to adjust the position of the particle
That will take a while as i want it to work perfectly on every model in the game
Yes, it will, but with no set standard for models size/dimensions you're going to have to do this.
I found a way to do it and it works perfectly, problem is that it has to run a trace like 10000 times for the biggest models which freezes my game for 2 seconds.
What exactly are you trying to do? There probably is another way to do what you need to do.
Im trying to spawn particles in the shape of the model and it has to work for every model in the game.
Yes, but why do you want to do this, what are you trying to achieve? If you can give more information about the final product, maybe we can help you some more
To create a crafting effect that appears when you craft a prop, there really isn't more to it than what I have already told you about.
I know there's a script floating around somewhere that lets you load a .mdl file as a list of triangles, so you could potentially use that and loop through the points (sparingly to prevent lag) to create your particles. It'd be a little more difficult to make it create particles inside areas of the model though, I presume.
Yeah GetMeshConvexes() does that. It’s gets the position of each point on every point of the physics mesh. I used that at first but for box models that only have 12 vertices (2 triangles per side) so there was only 36 particles spawning on those huge square blocks. Could possibly work if I filled every point in the vertices.
You're still gonna have 1000+ effects created on the same frame. Are you sure you wouldn't be better off going for another effect? Like "ThumperDust", model coming out of the ground, or easing in the model's alpha to 255?
Not sure what exact crafting effect will you be satisfied by, but try checking out render.DepthRange, there is a video showing an example usage, which makes for a nice crafting effect. If you plan to spawn thousands of particles into a model, that is going to be very expensive, and probably you would be better off with another effect.
Sorry, you need to Log In to post a reply to this thread.