playMaker

Author Topic: Constant scrolling background? [SOLVED]  (Read 2953 times)

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Constant scrolling background? [SOLVED]
« on: May 27, 2014, 07:28:58 AM »
Hi all, I'm surprised this hasn't been asked (I did a search - maybe it's under a different name?)

I want a background image to constantly scroll (al la Flappy Bird) - is there an easy way to do this in Playmaker?

Thanks  8)
« Last Edit: May 28, 2014, 07:52:40 PM by Alex Chouls »

Graham

  • Sr. Member
  • ****
  • Posts: 340
  • I Love Playmaker!
    • Portfolio
Re: Constant scrolling background?
« Reply #1 on: May 27, 2014, 01:36:14 PM »
If your background graphic tiles horizontally, you can simply combine a "Float Interpolate" with a "Set Texture Offset" action every frame.
More templates on the Unity Asset Store!

Disclosure: We are using affiliate links to our assets; we may receive a commission for purchases made through them. This helps us to continue developing and maintaining great products!

4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Constant scrolling background?
« Reply #2 on: May 27, 2014, 04:54:48 PM »
Thanks! I've given it a go and it doesn't seem to be working quite right. Here's the Float Interpolate and the background texture...



and here's the Texture Offset but it's just distorting the texture and it remains static...



Any idea where I'm going wrong?

 :D

Breadman

  • Full Member
  • ***
  • Posts: 185
  • Derp
Re: Constant scrolling background?
« Reply #3 on: May 28, 2014, 01:36:17 AM »
I can't offer any help on Graham's solution, but I can maybe offer a second method for you to try:

1.Create a new empty game object, call it "texture animator" or anything you like.

2.Create an FSM on this object, and add a global float variable called "bg texture offset" or whatever you'd like.

3.Use a "set property" action, targeting the material that you have applied to your background. The "property" variable should be set to "mainTextureOffset.X" (or possibly ".z"). The "X" variable should be set to the global variable you created earlier. Check the box "every frame".

4.In a new FSM (can be a second FSM on the same object, or a new object entirely), modify the global variable using float add every frame, or use the iTween actions. There are lots of ways to icnrease the value of a float, pick you favorite and make sure it's happening every frame to ensure constant motion.

Hope this helps!!



4ppleseed

  • Full Member
  • ***
  • Posts: 226
Re: Constant scrolling background?
« Reply #4 on: May 28, 2014, 01:15:27 PM »
That worked. I followed your instructions and then I just needed to add Every Second to the Float Add as well and it started scrolling.

Thanks guys :)