You beat me to it. After stepping away for a few day I just started to dissect the commands and vector math.
I created a script similar to yours, no need to post it. The only difference was that i used closetPointOnMesh. I didn’t experience the abrupt changes in direction you did, and the behavior seemed better.
Glad you posted your solution!
DCW
Oh!! What i think helps with the with this script and the deforming surface is to create a geoCache of the surface.
In your particles go to add dynamic attribute > general. Give it a name(like particle_rotate), make sure its a vector (for x,y,z), and check per particle array.
Rightclick your new attribute and runtime expressions before dynamics and type this in :
What this line does is bascially give them a random rotation of 0 and 360 degrees in x y z. You could ofc if you just wanted it to be in one angle change it to 0,360,360 or something.
Then under rotation options choose particle_rotate.
Remember tho that the will randomly rotate every single frame now, if you just want to create some randomness and have your geometry be still, you can scrub in the timeline untill you find a frame youre happy with and then just put // in front of the expression or delete it.
There’s some great information here, I have something I’ve been trying to do related to this.
I’m trying to create an enormous flock of bats that can be dynamically influenced. One problem I’m having is getting the direction of the individual bats and awareness of the other bats around it.
I don’t know what i’m doing wrong…
I guess that when it comes to scripting I get lost most of the times… :banghead:
Anyways, could someone help me figure out why this is not working for me? All I wanted is for the instances make a kind of grid with crosses, using the sphere as a dome with a cross on each vertex…
I used YDP scene file as a start and copied the expressions…
I uploaded my scene.
please, guys…
Thanks a lot!!!
I’m trying a variation of yours but i can’t seem to get it right! I work with the Z up and thus i’m attempting to modify your code for one with the Z up.
This is the expression that i’m creating:
// sets the orient axis for the instance
particleShape1.aimUp = <<0,0,1>>;
// get surface normal at particle position
vector $particlePos = particleShape1.position;
vector $normal = nearestPointOnMesh -ip ($particlePos.x) ($particlePos.y) ($particlePos.z) -nr -q pPlane1;
// orient the instance
particleShape1.aimDir = $normal;
// random rotation for Z axis
particleShape1.randomRotationZ = rand(360);
so i was mucking around with YourDaftPunks scene (thanks) and stimuli’s post trying to aim the poly planes to a camera in the y axis whilst maintaning the orientation to the surface.
i am trying to replicate a ground cover system in a game engine. don’t ask why, but I am!
i think stimulis solution for aiming would break the surface orientation?
He can add a custom attribute randomRotation and give and give it this expression :
particleshape1.randomRotation = rand(0,0.360,0)
and map it to the rotation, like that he will get random rotation on all the instances on the Y axis.
the bad thing about doing it with Index is that more indexes in the instances effect the ram during the rendering and slow down a bit the render if the objects instances get pretty big with complicated shader network complicated .
thanks
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.