Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: tinjaw on February 21, 2014, 09:53:21 PM

Title: How would I do this with Playmaker
Post by: tinjaw 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);
        }
}
}
Title: Re: How would I do this with Playmaker
Post by: redikann 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.