playMaker

Author Topic: Fix Spawned Background (Scrolling Background) Seam  (Read 2505 times)

rickmiranda

  • Playmaker Newbie
  • *
  • Posts: 11
Fix Spawned Background (Scrolling Background) Seam
« on: September 03, 2013, 06:52:26 PM »
Hi

I desperately need some help here. I tried to implement a scrolling background in Playmaker using the following set-up here, but have not received any potential solutions using this scheme:
http://hutonggames.com/playmakerforum/index.php?topic=4746.0

So instead, I'm implementing a script as follows:
------------------------
#pragma strict
var delta : float = 10 * Time.deltaTime;
var position_new : float;
var position_current : float;

function Start () {
}

function Update () {
delta = 10 * Time.deltaTime;
//var position_current : float = transform.position.y;
position_current = transform.position.y;

Debug.Log("delta:"+delta);
Debug.Log("Platform Position: "+position_current);
transform.Translate(Vector3.down * Time.deltaTime*15, Space.World);

   if (transform.position.y<-34.9999999)
   {
   position_new = position_current - Time.deltaTime*100 + 148;
   transform.position = new Vector3(65, position_new , 1);
   }

}
-----------------------------
Note that the scrolling background starts off with 3 scrolling tiles. Each one is 50 pixels long, for a total of 150 pixels between the first tile's center point and the last tile's center point.
Once the first platform reaches a certain point below the camera view, will set the position_current variable to the current position of the scrolling tile. Then adds 150 and spawns a new platform right where the last platform ends.

This seems to be working a lot better than my first implementation using the Playmaker FSM with spawn object. The tile seams do not occur as often and when they do occur, are much closer together and not as large. I subtract Time.deltaTime*100 because somehow I imagine that the tile beneath the new spawn will be incremented before the new tile is placed (I may be wrong not sure).

Anyway, I still get seams every now and then so wanted to put this out there to see if anyone has any recommendations.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Fix Spawned Background (Scrolling Background) Seam
« Reply #1 on: September 11, 2013, 05:02:22 AM »
Hi,

 look at this:

http://hutonggames.com/playmakerforum/index.php?topic=4510.msg21203#msg21203

 You'll see that actually, you don't really need 3 prefabs, with the help of some texture tweak :)

 Bye,

 Jean