playMaker

Author Topic: How would I do this with Playmaker  (Read 1500 times)

tinjaw

  • Playmaker Newbie
  • *
  • Posts: 24
How would I do this with Playmaker
« on: February 21, 2014, 09:53:21 PM »
I have the following script which I can attach to an object to get it to wrap around the screen. I would like to know how I would do this using Playmaker instead of a script.

I know it will involve using "Every Frame", however everything I have tried results in some kind of loop that Playmaker detects and stops after 1000 iterations.

Code: [Select]
using UnityEngine;
using System.Collections;

public class WrapScreen : MonoBehaviour {
    public float xPos, xNeg, yPos, yNeg;

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
        if (transform.position.x > xPos)
        {
            transform.position = new Vector3(xNeg, transform.position.y, transform.position.z);
        }

        if (transform.position.x < xNeg)
        {
            transform.position = new Vector3(xPos, transform.position.y, transform.position.z);
        }

        if (transform.position.y > yPos)
        {
            transform.position = new Vector3(transform.position.x, yNeg, transform.position.z);
        }

        if (transform.position.y < yNeg)
        {
            transform.position = new Vector3(transform.position.x, yPos, transform.position.z);
        }
}
}

redikann

  • Full Member
  • ***
  • Posts: 174
Re: How would I do this with Playmaker
« Reply #1 on: February 21, 2014, 10:58:51 PM »
You just need to gate your loop. A 'Send Event' and "Wait' action can achieve this.
Looking at the code it looks like if recreated in Playmaker there would be a threshold where playmaker would get caught in a loop so try and add a little padding to your float compares if you are using them.
« Last Edit: February 21, 2014, 11:03:23 PM by redikann »