# How could i get this random facing but rotate by a direction in instance?

## Recommended Posts

pre random rotation then orient..

hi!Some questions,just can`t get this effect in instance!could anyone help~!thx!

rotate_in_copy_H15.hip

##### Share on other sites

Could you explain in more detail what you are trying to achieve? Do you want the particles to first have a random rotation applied, and then be rotated based on the particles velocity?

##### Share on other sites
On Saturday, August 20, 2016 at 4:30 AM, MirrorSword said:

Could you explain in more detail what you are trying to achieve? Do you want the particles to first have a random rotation applied, and then be rotated based on the particles velocity?

yes,that`s what i want.sorry about my english,just can`t get an idea to deal with this keep random rotation state first in instance

##### Share on other sites

So I made an example of how I would accomplish that task. If you check out this page. You'll see that the "rot" attribute is a final rotation applied after all the other rotations. So if your points have "v" and "rot" attributes, the objects will first be rotated in the direction of the velocity and then rotated by the "rot" quaternion. I also calculate the "rot" attribute before the particle system so that it won't change during the simulation (although it shouldn't matter for this example). to calculate the rot attribute I use the point number to create a random vector within the range 0 to 1 and then remap it to the range -1 to 1.  I then normalize that and use "look at" to convert it to a matrix that points in that direction, and then finally convert that matrix to a quaternion. There's probably a better way to calculate that but this works.

Anyway let me know if you have any questions.

rotate_in_copy_v2.hip

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account