• 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 PICHU · Dec 09, 2013 at 08:16 AM · tilemapscaling

trying to stretch an object along with its material

I'm trying to do a snake game in unity3D. i need some help with stretching or scaling an object along with its material(tileable). can it be done in unity. I need to scale the cube as it picks up the object with its material via scripting.. can any one help pls???

Comment
Add comment · Show 1
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 CHPedersen · Dec 09, 2013 at 08:21 AM 0
Share

You have to play with the cube's transform.lossyScale as well as the material texture's Tiling property. I.e. setting the cube's scale to 2 in some direction means you'll have to also set the texture's Tiling to 2 to prevent it from stretching. Post your code, then we can work at it from there.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by highpockets · Dec 09, 2013 at 09:57 AM

I think you will want to make a prefab of the portion of the snake that gets bigger. I'm imagining that the snake gets longer as it eats objects, so making a prefab of a portion of the body would be your best bet I think. That way you can just instantiate the prefab when the snake eats something and to make the transition smooth, instantiate the prefab with the scale of the axis that gets bigger set to 0 and incrementally increase the scale of that axis at the same speed as you make room for the new portion of the snake. I'm assuming that your snake's head and tail will stay the same size and therefore you won't have to touch the scale of those, but just translate them away from each other as the new portion of the snake materializes.

You won't have to worry about tiling as the prefab will take care of that.

BTW transform.lossyScale is Read only. You will have to use localScale

Comment
Add comment · Show 2 · 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 CHPedersen · Dec 09, 2013 at 10:01 AM 0
Share

True, to the letter. :) Do this.

Also, a solution with prefabs allows you to, you know, change direction. ;) It'll be a very quick, boring game of snake without that bit.

avatar image PICHU · Dec 10, 2013 at 07:31 AM 0
Share

thanks, I'll Give it a try.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

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

changing camera view 3 Answers

Problem scaling parent without scaling child 0 Answers

GUI box scaling issue [C#] 0 Answers

Is this the correct way to scale my GUI? 1 Answer

Scaling Moves Objects 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