krishna avril Posted March 19, 2021 Share Posted March 19, 2021 Hi, I'm trying to instance different geometry on points, but the instanced object is chaning its object every frame, since the point numberis chaning, tried adding the id, I'm not sure where it got wrong, can someone help me here, copy_instance chaning_problem.hip Quote Link to comment Share on other sites More sharing options...
underscoreus Posted March 19, 2021 Share Posted March 19, 2021 Heyo, Had a look at your hipfile and it seems your issue was twofold, number one was that you were using "@ptnum" for your random value. In this case that does not work since you are spawning and killing particles in your pop sim (note that this would actually be fine if you were not killing your particles since they do maintain propper point number order as long as no points die). Another note from where you were setting you variant attribute, the rand function gives you a random floating-point number (fancy way of saying a number with decimals) between 0 and 1, if you want it to give you a value between a certain range, like in your case a value between 0 and 3, you'll need to use one of the fit functions to change the range from 0 - 1 to 0 - 3. Below is the vex expression I made to make it work (It gives a small warning because it is converting the float value from the fit01 expression to an integer value but that's fine): i@variant = fit01(rand(i@id, chf('Seed')), chi('Min_Num'), chi('Max_Num')); I am using the "id" attribute instead of the "ptnum" attribute, the "id" attribute is something that you don't need to create before the sim since it's something the sim makes itself. It is basically just a perfect ordered number for the particles, exactly what we need here. Next I just set up some sliders for easy control of the minimum and maximum values you want out of it. Something to note is that the rand function pretty much never produces a perfect value of 1 or 0 so for your max number you might want to add 1 to the value to make your last value happen more frequently than it would naturally. The second issue is the attribute randomize node you are using for pscale, unfortunately, the attribute randomize uses "@ptnum" to create its random value, and since "@ptnum" changing here, so does your random pscale. However, not to fear, we can just use the exact same expression as above! f@pscale = fit01(rand(i@id, chf('Seed')), chf('Min_Scale'), chf('Max_Scale')); Lastly just as an extra bit, the copy to points method needs some attribute to tell it about what way to orient the geometry, whether it is N, v, up, orient, etc. Since your sim only had v, the objects start out laying flat and then rotate on their second frame of life since they then have some values in v, I've just added a N attribute to them to make it consistent but you might want to change that, maybe a random direction vector or however you want to orient the pieces. Hope that can help, Good luck! copy_instance_chaning_problem_mnb.hiplc 2 Quote Link to comment Share on other sites More sharing options...
krishna avril Posted March 19, 2021 Author Share Posted March 19, 2021 Appreciated man! Thank You very much! That's a Great Explanation, Now it makes sense. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.