playMaker

Author Topic: [SOLVED] Setting impact rotation particles from Raycast  (Read 1933 times)

daniellogin

  • Full Member
  • ***
  • Posts: 215
[SOLVED] Setting impact rotation particles from Raycast
« 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?
« Last Edit: March 06, 2018, 09:30:05 AM by daniellogin »

terri

  • Sr. Member
  • ****
  • Posts: 389
    • terrivellmann.tumblr.com
Re: Setting impact rotation particles from Raycast
« Reply #1 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.

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Setting impact rotation particles from Raycast
« Reply #2 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?

terri

  • Sr. Member
  • ****
  • Posts: 389
    • terrivellmann.tumblr.com
Re: Setting impact rotation particles from Raycast
« Reply #3 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
« Last Edit: March 01, 2018, 04:37:52 PM by terri »

daniellogin

  • Full Member
  • ***
  • Posts: 215
Re: Setting impact rotation particles from Raycast
« Reply #4 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.
« Last Edit: March 01, 2018, 04:40:33 PM by daniellogin »