playMaker

Author Topic: Scrolling Background  (Read 7217 times)

rickmiranda

  • Playmaker Newbie
  • *
  • Posts: 11
Scrolling Background
« on: July 27, 2013, 02:16:49 PM »
Looking for some help with using FSM to create a scrolling background. I've created a prefab, it scrolls in one direction. When it gets to a certain point, I want another prefab to spawn and join with the existing prefab while they both continue to scroll. When the old prefab object gets to a point not viewed by the camera, I want the old prefab object to destroy itself. The spawn new prefab continues to link to the older prefab and so on...I think I've implemented this but having some issues where the new prefab is created at the same time the old one is destroyed so I get a gap where there's no background.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Scrolling Background
« Reply #1 on: July 28, 2013, 08:05:31 AM »
Hi,

 you are on the right track. The key is to have 2 background active at all time, not one.

so, using your exact same logic, you only destroy a background prefab when it's twice as far as its width. Does that make sense?

IF you follow this logic, you'll also find that you don't need to create any new prefab, instead simply reposition the one that is twice as far. this will be a lot more efficient as well.

bye,

 Jean

rickmiranda

  • Playmaker Newbie
  • *
  • Posts: 11
Re: Scrolling Background
« Reply #2 on: July 29, 2013, 09:44:39 PM »
Thank you Jean. I will keep that in mind. Basic implementation is to start the scene off with two prefabs, then destroy the one that is scrolling down once it is twice as far away as it's width.

What object do you create to join with the higher prefab, are you creating the same prefab...? Any additional info or steps will be great. Thanks.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Scrolling Background
« Reply #3 on: July 30, 2013, 05:51:15 AM »
hi,

 Actually, as I went into making a sample, I realized there is a much better approach to all this, simply by scrolling the texture itself. This means, not prefab, not management of objects positionning, so it's very simple to implement.

 Please find attached a sample. you'll notice that to achieve several "instance" of your background, simply adjust the scaling of both the mesh and the material texture scale, in that example, I have twice the background showed on the mesh.

Bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Scrolling Background
« Reply #4 on: August 02, 2013, 05:57:57 AM »
Hi,

Here is another example using this time gameObject. it's to implement endless roads, but basically, it's exactly the same for a scrolling background, you just need to position your camera and blocks differently, that's all.

http://hutonggames.com/playmakerforum/index.php?topic=4550.0

bye,

 Jean

pilotjoe

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Scrolling Background
« Reply #5 on: February 16, 2015, 10:04:36 PM »
Hello Jean,
I know this thread is quite old, but I was following along with the sample and decided to try to make a small change I just could not seem to get working.

In your sample you have the entire rig (cube, light, camera, triggers, etc) move down the road.

My change was to keep the rig stationary while animating (scrolling the road).

I was able to get the rig to stay put and scroll the road, however the spawning and destroy of the road gameObject was not happening. 

I created new FSM's (actually copied the FSM's from EndlessRoad object) to an empty game object called Roads that was a parent of the road prefabs.

Not sure what I was doing wrong.  Attached is a quick screen shot. Not sure if you have some suggestions.

many thanks!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Scrolling Background
« Reply #6 on: February 17, 2015, 04:01:56 AM »
Hi,

 It's difficult without being able to study your fsms. Can you pm me with your email, and if you can shre that scene, then I'll have a look.

 Bye,

 Jean

pilotjoe

  • Playmaker Newbie
  • *
  • Posts: 3
Re: Scrolling Background
« Reply #7 on: February 17, 2015, 08:42:59 PM »
Hello Jean,
thanks for replying.  I've exported the scene and saved on my dropbox folder.  It was just a bit too large to attach.  I will PM you my email address too..

Thanks again!

https://www.dropbox.com/s/atq1z19nwiw8shu/EndlessRoad-movingRoad.unitypackage?dl=0

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Scrolling Background
« Reply #8 on: July 23, 2015, 09:24:40 AM »
Hi,

 I know it's an old post but I am trying to go trhough my pending work...

Where you able to sort it out in the end? Typically, in your case, I would not touch anything logic wise but simply rotate the background so that it's flat and then it becomes a road basically...

Else, I wanted to download your package but it's not there anymore.

Bye,

 Jean

Raknill

  • Playmaker Newbie
  • *
  • Posts: 20
Re: Scrolling Background
« Reply #9 on: January 24, 2017, 09:00:32 PM »
Just wanted to bump this old thread to see if Jean or anyone has a solution to to the problem of floating point errors that you would run into with the current setup.

Been trying to get an "endless driver" going for a bit now, and I'm pretty close. The package Jean posted up above helped a ton.

Thanks in advance for any help!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Scrolling Background
« Reply #10 on: January 26, 2017, 01:39:00 AM »
Hi,

 can you explain what you mean by floating point error?

 Bye,

 Jean