playMaker

Author Topic: Converting variables from JavaScript to Playmaker?[SOLVED]  (Read 2169 times)

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Converting variables from JavaScript to Playmaker?[SOLVED]
« on: June 04, 2013, 05:01:00 PM »
Hi all, I have this code from a tutorial:
Code: [Select]
var emptySlot : Transform ;
var xtemp;
var ytemp;

function OnMouseUp() {
if (Vector3.Distance(transform.position,emptySlot.position)==0.5)
{
xtemp=transform.position.x;
ytemp=transform.position.y;
transform.position.x=emptySlot.position.x;
transform.position.y=emptySlot.position.y;
emptySlot.position.x=xtemp;
emptySlot.position.y=ytemp;
}
}

It works fine but I'd like to convert it to 100% Playmaker. The first var is a Transform variable - what is the equivalent in Playmaker? What type of variables are var xtemp and ytemp if I was to recreate them in Playmaker? String?

I'm a bit confused, so any help would be great, thanks.
« Last Edit: July 09, 2013, 07:12:31 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Converting variables from JavaScript to Playmaker?
« Reply #1 on: June 05, 2013, 01:23:41 AM »
Hi,

 xTemp and yTemp are floats.

but in your case, simply save the position in a vector3, call it temp
then set your transform position with the emptySlot
and then set the empty slot position to temp.

bye,

Jean

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Converting variables from JavaScript to Playmaker?
« Reply #2 on: July 09, 2013, 05:53:51 AM »
Thanks Jean. This worked well  8)