playMaker

Author Topic: Help with Quaternions in Playmaker  (Read 1942 times)

Matthew

  • Playmaker Newbie
  • *
  • Posts: 15
Help with Quaternions in Playmaker
« on: February 27, 2014, 08:23:23 PM »
Hi guys, I am making a game where a player can walk up walls and on ceilings. I have a player with a rigidbody and am freezing the rotation.  I have an FMS for keeping a constant -y self force and moving the player forward with a z force.    I also have this code that always keeps the bottom of the player aligned with the ground using a raycast and it works fine (always keeps the transform rotation flush with the floor).  But I can not get it to work in playmaker.   I downloaded all the custom actions required off the website (Quaternion.LookRotation, Transform.right) but just can't get it to work.  Can anyone help?  Thanks!

Code: [Select]
if (Physics.Raycast (transform.position, -transform.up, out hitDown, 2))
{
transform.rotation = Quaternion.Lerp (transform.rotation, Quaternion.LookRotation (Vector3.Cross (transform.right, hitDown.normal), hitDown.normal), Time.deltaTime * 5.0f);
}


jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Help with Quaternions in Playmaker
« Reply #1 on: March 06, 2014, 07:38:55 AM »
Hi,

 first, are you positive that this snippet works? if you have a scene with that script that works, I can then make it work as a 100% playmaker solution.

bye,

 Jean

Matthew

  • Playmaker Newbie
  • *
  • Posts: 15
Re: Help with Quaternions in Playmaker
« Reply #2 on: March 06, 2014, 02:42:34 PM »
Thanks for responding Jean.  Yes the code works.  I tried to copy it in playmaker using two states that loop (detect raycast hit state, then rotation calculation state) but no luck.  I am using a "next frame event" at the end of the "rotation calculation state" to return back to the the "detect raycast hit state".   I also tried "wait" to transition back but no luck.   In playmaker the player will align flush to the floor but when I rotate the player around (using the mouse) the player rotation gets all whacky and the player flips.  But as I said the C# code works perfectly. 

Thanks!
Matthew

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Help with Quaternions in Playmaker
« Reply #3 on: March 11, 2014, 07:17:09 AM »
Hi,

 It really depends how this snippet is ran and when, so as I said, if you have a test scene where this is implemented, I'll be able to turn that into a 100% playmaker scene.

bye,

 Jean