Hi all,
I'm trying to figure out a way to rotate/ spin particles around their velocity direction - e.g. like a bullet which spins when fired.
My first approach was using the Aim Position and the Aim Up Axis in the Instancer options. The aim Up axis vector is rotated around the velocity vector by a runtime expression:
particleShape1.aimUpAxisPP = rot(particleShape1.aimUpAxisPP,particleShape1.velocity,deg_to_rad(5));
This works for some particles but a lot of them are flipping when they change direction.
My second approach tries to use the instancer rotation. But here I'm stuck. I try to use this runtime expression to calculate the changed rotation of the velocity vector:
//CREATION EXPRESSION:
particleShape1.oldVecForwardPP = <>;
particleShape1.oldPosition = particleShape1.position;
particleShape1.oldVecSidePP = <>;
particleShape1.oldVecUpPP = <>;
particleShape1.myRotPP = <>;
//RUNTIME EXPRESSION
//generate vectors to use for rotation calculation: forward, side, up
vector $forwardVec = unit(particleShape1.position - particleShape1.oldPosition);
vector $newVecSide = cross($forwardVec, <>);
vector $newVecUp = cross($newVecSide, $forwardVec);
//calculate rotation
particleShape1.rotX_PP = rad_to_deg(angle( particleShape1.oldVecForwardPP, $forwardVec));
particleShape1.rotY_PP = rad_to_deg(angle( $newVecSide,particleShape1.oldVecSidePP));
particleShape1.rotZ_PP = rad_to_deg(angle( $newVecUp,particleShape1.oldVecUpPP));
//assign rotation
particleShape1.myRotPP += <>;
//store values for later time
particleShape1.oldVecForwardPP = $forwardVec;
particleShape1.oldPosition = particleShape1.position;
particleShape1.oldVecSidePP = $newVecSide;
particleShape1.oldVecUpPP = $newVecUp;
But for some reason this does not work as expected. Am I thinking to complicated? Perhaps somebody can point me in the right direction. Thanks in advance!