playMaker

Author Topic: Help recreating code in playMaker[SOLVED]  (Read 1052 times)

spiralKing

  • Junior Playmaker
  • **
  • Posts: 50
    • View Profile
Help recreating code in playMaker[SOLVED]
« on: February 27, 2014, 10:15:15 AM »
I've been looking for a way to rotate a wheel with touch or mouse and I finally got some help

e.g.

I just need help figuring out how to recreating this code in playmaker

Code: [Select]
#pragma strict
 
private var baseAngle = 0.0;
 
function OnMouseDown()
{
    var dir = Camera.main.WorldToScreenPoint(transform.position);
    dir = Input.mousePosition - dir;
    baseAngle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
    baseAngle -= Mathf.Atan2(transform.right.y, transform.right.x) * Mathf.Rad2Deg;
}
 
function OnMouseDrag()
{
    var dir = Camera.main.WorldToScreenPoint(transform.position);
    dir = Input.mousePosition - dir;
    var angle =  Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg - baseAngle;
    transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
}
« Last Edit: April 10, 2014, 09:54:09 AM by spiralKing »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14703
  • Official Playmaker Support
    • View Profile
Re: Help recreating code in playMaker
« Reply #1 on: March 04, 2014, 04:52:27 AM »
Hi,

 ok, you'll need the trigonometric custom actions and the quaternion custom actions:

https://hutonggames.fogbugz.com/default.asp?W971
https://hutonggames.fogbugz.com/default.asp?W967

the other functions are available as official actions in playmaker itself.

if you have problems making it all into playmaker get back to me, I'll see what I can do ( running behind big time on the forum, so you'll have to bump this in few days).

bye,

 Jean

Mateo

  • Playmaker Newbie
  • *
  • Posts: 3
    • View Profile
Re: Help recreating code in playMaker[SOLVED]
« Reply #2 on: November 25, 2016, 01:20:10 PM »
Hi! Want to do the same thing! Can you tell me how you did it?

EDIT:
Solved it! Too easy...

Actually I wanted to do a drag and drop. And I followed this tutorial:
Cheers!
« Last Edit: November 26, 2016, 07:00:10 AM by Mateo »