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 fjalla · Mar 17, 2013 at 05:37 PM · textureinstantiatetimetexture offset

Problem with time on scrolling texture

Hi. I've got a script:

 var scrollSpeed = 0.25;
 
 function FixedUpdate() 
 {
     var offset = Time.time * scrollSpeed;
     renderer.material.mainTextureOffset = Vector2(0,offset);
 }


The problem is that I have the script on an object that is instantiated while playing, so the offset is bigger if you create the object later in the game.

I'm sure I missed something but I don't know how to fix it. Please help.

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
Best Answer

Answer by robertbu · Mar 18, 2013 at 06:00 AM

Create your own timer or you can subtract the start time:

 var scrollSpeed = 0.25;
 private var startTime = 0.0;
 
 function Start() {
   startTime = Time.time;
 }
  
 function FixedUpdate()  {
     var offset = (Time.time - startTime) * scrollSpeed;
     renderer.material.mainTextureOffset = Vector2(0,offset);
 }
Comment
Add comment · Show 6 · 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 fjalla · Mar 18, 2013 at 05:10 PM 0
Share

thanks! But when I try it on the tiling of a texture it doesn't work. It only sets the tiling to that number...

 var tiling = (Time.time - startTime) * tileSpeed;
         renderer.material.mainTextureScale = Vector2(0,tileSpeed);

Can you help?

avatar image robertbu · Mar 18, 2013 at 05:29 PM 0
Share

I might be able to help if I can better understand the problem. This code above will start the texture at the beginning (offset 0) at the time the object is created. What exactly are you seeing and what problem are you trying to fix.

avatar image fjalla · Mar 18, 2013 at 05:39 PM 0
Share

I need the tiling of the texture to get bigger every second, but with the same speed on every object or computer

avatar image whebert · Mar 18, 2013 at 05:46 PM 1
Share

Doctor Jellyface, did you mean to put Vector2(0, tileSpeed) above? Shouldn't it be Vector2(0, tiling)?

avatar image robertbu · Mar 18, 2013 at 06:06 PM 0
Share

You changed questions on me. The original question was about offset, now you are asking about scale. The issues is that you are putting in '0' for an X scale. Use this ins$$anonymous$$d:

renderer.material.mainTextureScale = Vector2(1,tileSpeed);

...or whatever value you want for x.

Show more comments

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

11 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

Related Questions

Animated Texture and Instantiation 1 Answer

How to make something happen over time? 1 Answer

Problem with missing texture with Instantiate( Resources.load ) method 0 Answers

Timed instantiantion not quite working 1 Answer

Cycle Textures Over Time 2 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