Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by cowmoooooo · Feb 14, 2014 at 06:15 PM · camerabackgroundscrolling

How do I get something that goes off camera to appear on the opposite side ?

First post here, I've found plenty of help on the site otherwise but I can't seem to find an answer for my question. Basically, I just want my background to slide off camera but appear on the other side. Just vertically scrolling. I have the background sliding up now but I can't figure out where to go from here..(I'm pretty novice coding wise btw). Any help would be great.

I can only think of something else I read which was make a cylinder and make it turn with a texture on it. I can post my code if need be but it's just the basic Time.deltaTime code with a variable.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by robertbu · Feb 14, 2014 at 06:27 PM

This is often done by Material.SetTextureOffset(), which rotates the texture, not the whole game object. There is example code in the reference. Plus if you Google "Unity SetTextureOffset" you will find other examples.

I found your rotating cylinder idea creative and potentially workable...especially unlit and especially for an Orthographic camera.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cowmoooooo · Feb 14, 2014 at 06:57 PM 0
Share

Thanks for the quick response. After doing a quick search on the settextureoffset, if I'm understanding correctly the material scrolls on the object(via plane/cube etc) ins$$anonymous$$d of the entire thing moving right ??

avatar image robertbu · Feb 14, 2014 at 07:15 PM 0
Share

Correct. A Quad is a good choice for a background. Note from your title, I though you wanted something more like asteroids where an object disappears on one side and then reappears on the other, but your 'cylinder' idea pointed me towards SetTextureOffset(). Note the 'Wrap $$anonymous$$ode' for the texture you use must be set to 'Repeat' for SetTextureOffset() to work.

avatar image cowmoooooo · Feb 14, 2014 at 07:42 PM 0
Share

I got it working pretty well. The SetTextureOffset is perfect. I have it on a plane right now, how come a quad would be a better choice ?? Also how would I go about changing it to a vertical scroll rather than horizontal. I played with the code a bit but kept getting compile errors.

Also with the cylinder wouldn't it look odd ? because part of the texture would be slightly further back from the camera ?? Like the top and bottom would be further back than the middle.

avatar image robertbu · Feb 14, 2014 at 10:08 PM 0
Share

When a Quad has (0,0,0) rotation it's visible back is to the camera when the camera has (0,0,0) rotation. So it is a nice way to display a texture for a standard/default setup. Plus a Quad only has 2 triangles.

You need to change the Vector2 passed for vertical:

 renderer.material.SetTextureOffset("_$$anonymous$$ainTex", new Vector2(0, offset));

As for the cylinder, how much distortion would be based on how much of the cylinder was visible on the screen. If the cylinder was significantly bigger than the screen, then the distortion would be $$anonymous$$imal and would look okay. SetTextureOffset() is a much better solution (I$$anonymous$$HO), but I liked the way you came up with a solution using the tools you knew.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I have the background for the main camera in a scene display the feed from a web cam/camera on a phone? 1 Answer

Resolution Independent Scrolling Background 0 Answers

How to script a repeating environment texture 3 Answers

Randomly Transition Camera Background Color? 2 Answers

Most efficient way to darken the screen? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges