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 Anonymous 1 · Dec 04, 2011 at 09:28 AM · collisiontexturecolorplatform

Texturing/Coloring wherever you go

I am working on a 3D Platform-ish game... Its basic scheme is Black and White-ish what i want is that where ever the player object goes from that area (not that specific place but the whole area ) should get colored/textured a little help will be appreciated. Thank You!

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 gregzo · Dec 04, 2011 at 11:05 AM

Hi! I'm not sure I understand your definition of place/area. Assuming you have 4 rooms on screen, each room an "area", you could do the following:

1-add the following script to every object you want to be affected

 var basicTexture : Texture;
 var colouredTexture : Texture;
 function Start()
 {
       renderer.material.mainTexture = basicTexture;
 }
 function SwapTexture()
 {
       if(renderer.material.mainTexture == basicTexture)
       {
             renderer.material.mainTexture = colouredTexture;
       }
       else
       {
              renderer.material.mainTexture = basicTexture;
       }
 }

2-make all objects of a room("area") children of a trigger (invisible flat cube, isTrigger enabled) -Add the following script to your triggers

 function OnTriggerEnter(coll: Collider)
 {
    if(coll.tag == "player")  // tag or name or transform whatever works for you
    {
         BroadCastMessage("SwapTexture");
    }
 }

 function OnTriggerExit(coll:Collider)
 {
    if(coll.tag == "player")  // tag or name or transform whatever works for you
    {
         BroadCastMessage("SwapTexture");
    }
 }

It's rough, but should work. You could refine it by having one or two intermediate textures to smooth it out.

P.S.: I'm new to Unity, but this question seemed like one I could answer quite safely. @More experience coders : if my reply is inadequate please enlighten me, as I'm sure there are more elegant ways of doing this...

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 Anonymous 1 · Dec 04, 2011 at 11:46 AM 0
Share

the problem is I have a big object and if i need to use this script i would have to divide that object into small-small parts..

avatar image Anonymous 1 · Dec 04, 2011 at 11:46 AM 0
Share

the problem is I have a big object and if i need to use this script i would have to divide that object into small-small parts..

avatar image gregzo · Dec 04, 2011 at 01:28 PM 0
Share

Then maybe use a spotlight that follows the player? Greyish, low intensity ambient light, wide spotlight following the player? If you give more details, I'm sure help can be more precise!

avatar image Anonymous 1 · Dec 05, 2011 at 03:22 PM 0
Share

alright .. imagine the racing game where there are no colors and a colorful car races through the track making it colorful over the area it go .. not only specific places it go but whole back area where it is co$$anonymous$$g from ..

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Finding color of a body at the point of collision with another body? 1 Answer

Detect if ball is on a platform or if it fell 4 Answers

Editing Texture during Run time causing Unity Editor to Crash 1 Answer

Adding sound javascript in unity2d 1 Answer

How to color text smoothly or how to color part of a letter? 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