Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 RaduMitroi · Aug 28, 2017 at 08:37 PM · textureoffsetworld space

Offset texture based on world space

I'm looking for a way to make an object's texture offset when I move it in the scene. Let's say I have a cube, a 1024x1024 texture atlas divided in 4 equal parts with 4 different colors (red, green, blue, and yellow; just as an example), and the cube's UV will cover one of those 4 sides, so it will show one of the four colors. How do I make the texture continuously offset while I move the cube in my scene, so that everytime I move it, it will show one of the colors on the texture atlas? And if I keep moving it, it will keep scrolling through the four colors, over and over again.

I was thinking of having the texture offset half way in a direction so it will show one of the other colors, but I don't know how to make that happen while the cube's position changes in my scene. Can someone point me in the right direction?

Thank you.

Comment
Add comment · Show 2
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 instruct9r · Aug 28, 2017 at 09:22 PM 0
Share

Do you want to do it with 3D object (Cube) or a plane? If it's Cube, it will be harder. I'd like to give it a try, but i just want to be sure that you want to do it with cube exactly??

avatar image RaduMitroi instruct9r · Aug 28, 2017 at 09:37 PM 0
Share

I actually want to be able to do it with any kind of 3D model I have. So it doesn't matter if it's a cube, a wall, or a car. As long as I've got an unwrapped 3D model and a specific texture atlas for that model, it should work. i didn't find anything on google about changing textures, offset, or changing any kind of values while the object is moving in world space.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by pslattery · Aug 29, 2017 at 01:12 AM

If you're using the built in Standard Shader (I'm sure some of the other shaders do this too, but I'm not in front of Unity and can't check) you can change the Offset property to move the texture.

Basically,

  1. Store your current position as the last position you have 'stepped' the texture offset at

  2. Every update, check to see if you've moved more than some threshold, in x and y each. If you have:

  3. Update the objects material property Offset x or y (corresponding to which direction you moved in) to equal its current value + .5 (the distance across half the texture in UV space).

Hope this helps!

Comment
Add comment · Show 1 · 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 RaduMitroi · Aug 29, 2017 at 01:49 AM 0
Share

Isn't that going to work only at runtime? I want that continuous offset to happen while moving the object in your viewport and update in realtime, without needing to hit play. The effect should be happening immediatly as you drag and drop your model from the project to the scene and start moving it around (assu$$anonymous$$g it's got the script attached).

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

91 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 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 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 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 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 avatar image

Related Questions

Bullet Mark Texturing offset too far 1 Answer

Texture offset only on enemy death 0 Answers

SkinnedMeshRenderer offset UVs to match texture atlas? 1 Answer

The correct way of making Texture Atlas 0 Answers

Masking a plane object (which has an animated texture offset) 1 Answer


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