Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: spiralKing on February 27, 2014, 12:15:15 PM
-
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
#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);
}
-
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
-
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!