Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: daniellogin on March 01, 2018, 12:09:34 PM

Title: [SOLVED] Setting impact rotation particles from Raycast
Post by: daniellogin on March 01, 2018, 12:09:34 PM
I'm setting up a a gun system with Raycast. I have it so particles are created on the position that is hit, but the particles are always the same rotation (so nearly always wrong).

What is the process to have the particles corrected so the ground points the particles up, the wall points the opposite way it was impacted, etc?
Title: Re: Setting impact rotation particles from Raycast
Post by: terri on March 01, 2018, 03:45:47 PM
When you raycast, store the Hit Normal. Use the action Quaternion Look Rotation, set the Direction to the Hit Normal value and the the Up Vector to 0, 1, 0. Store the result and set your particles rotation to that.
Title: Re: Setting impact rotation particles from Raycast
Post by: daniellogin on March 01, 2018, 04:27:33 PM
When you raycast, store the Hit Normal. Use the action Quaternion Look Rotation, set the Direction to the Hit Normal value and the the Up Vector to 0, 1, 0. Store the result and set your particles rotation to that.
There seems to be a problem with this or perhaps a step missed.

When I use the 'Quaternion Look Rotation', I can input the Hit Normal as the direction and 0,1,0 as the Up Vector, but when I store the result it can't be used as the rotation variable for Create Object. It doesn't show in the list.

Is this instruction missing some kind of conversion step or something?
Title: Re: Setting impact rotation particles from Raycast
Post by: terri on March 01, 2018, 04:34:56 PM
The variable is a quaternion, so when you set the rotation use that field with the variable. Leave "Euler Angles" as none

edit: Oh, ok, with the create object action that isn't an option. Can you store the spawned gameobject and set the rotation right afterwards? Otherwise a tweak to the create object action would make it work

there is also a Get Quaternion Euler Angles action that might do the trick but haven't tested it
Title: Re: Setting impact rotation particles from Raycast
Post by: daniellogin on March 01, 2018, 04:38:31 PM
The variable is a quaternion, so when you set the rotation use that field with the variable. Leave "Euler Angles" as none

edit: Oh, ok, with the create object action that isn't an option. Can you store the spawned gameobject and set the rotation right afterwards? Otherwise a tweak to the create object action would do the trick
Thanks for your help.

I realised it was a Quaternion variable and not a Vector3, so I googled how that would convert. What I found was about scripting but it put me on to Euler Angles. I got it working by using the 'Get Quaternion Euler Angles' action to convert it to Vector3.