Playmaker Forum
PlayMaker News => General Discussion => Topic started by: rickmiranda 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.
-
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
-
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.
-
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
-
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
-
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!
-
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
-
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
-
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
-
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!
-
Hi,
can you explain what you mean by floating point error?
Bye,
Jean