Hi
Can anyone convert the below javascript to Playmaker please. It's a handy script for tipping a box of any dimension on it's edge. (Doesn't work with Probuilder though).
(Update - it does work with Probuilder as long as you edit the Probuilder Pivot so it's centered to the box).
I cannot code to save my life, which is why I'm using Playmaker of course.
The person who does do this could either make an FSM or Youtube vid on how to get a box of any dimension to tip over it's edge.
Not bothered about the Audio and input part.
Thanks in advance.
#pragma strict
private var rotator : Transform;
var speed = 5;
var rotating = false;
function RotateCube(refPoint : Vector3, rotationAxis : Vector3)
{
// audio.PlayOneShot(audio.clip);
if (GetComponent.<AudioSource>()) GetComponent.<AudioSource>().Play();
var size = GetComponent.<Renderer>().bounds.extents;
refPoint = Vector3.Scale(refPoint - Vector3.up,size);
rotator.localRotation = Quaternion.identity;
rotator.position = transform.position + refPoint;
transform.parent = rotator;
var angle : float = 0;
while(angle < 90.0)
{
angle += Time.deltaTime*90.0*speed;
rotator.rotation = Quaternion.AngleAxis(Mathf.Min(angle,90.0),rotationAxis);
yield;
}
transform.parent = null;
rotating = false;
}
function Start()
{
rotator = (new GameObject("Rotator")).transform;
}
function Update ()
{
if (!rotating)
{
if (Input.GetKeyDown(KeyCode.D))
{
rotating = true;
RotateCube(Vector3.right,-Vector3.forward);
}
else if (Input.GetKeyDown(KeyCode.A))
{
rotating = true;
RotateCube(-Vector3.right,Vector3.forward);
}
else if (Input.GetKeyDown(KeyCode.W))
{
rotating = true;
RotateCube(Vector3.forward,Vector3.right);
}
else if (Input.GetKeyDown(KeyCode.S))
{
rotating = true;
RotateCube(-Vector3.forward,-Vector3.right);
}
}
}