Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 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
1
Question by Halo500 · May 13, 2013 at 03:26 AM · texturestaticoffset

How to make a plane with a texture flicker, as if it was animated?

I am trying to make a death scene in my game similar to the one in the Slender games. When you die, you would see the monster's face and static would flicker all over the screen.

I have the face ready in front of the Main Camera and I have a plane placed in front of the face, closer to the camera. I added the static texture, but my question is:

Is there a script that makes the texture's offset randomize all the time, making it look as if the static is moving?

I have this happening when I see the monster within the actual game, from this helpful guide, but I want to make this death scene and I am totally in the dark at the moment...

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 AlucardJay · May 13, 2013 at 03:36 AM 0
Share

Ummm, you already have the script for that. $$anonymous$$y static offset function in the PlayerHealth script.

 function Offset$$anonymous$$ainTexture() 
 {
     var rndXoffset : float = Random.value;
     var rndYoffset : float = Random.value;
     
     staticRenderer.material.mainTextureOffset = Vector2( rndXoffset, rndYoffset );
 }

http://docs.unity3d.com/Documentation/ScriptReference/$$anonymous$$aterial-mainTextureOffset.html

avatar image Halo500 · May 13, 2013 at 03:41 AM 0
Share

Hey alucardj! I got the script for the player health, but I am looking for the static texture to just flicker all by itself. Without the need of a player or health of any kind.

I have a scene called "SceneLose" (from your old guide) and I just have a black skybox for the entire background, slender man's face right up on the camera, and I just have a plane with the static texture.

Would I just create a new script and reference it to your static offset function in the script?

1 Reply

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

Answer by AlucardJay · May 13, 2013 at 03:48 AM

This is where I'm giving you the key but I want you to open the door yourself.

There is a gameObject, with a renderer that has a material :

 renderer.material

You want to offset the texture on that material : http://docs.unity3d.com/Documentation/ScriptReference/Material-mainTextureOffset.html

 renderer.material.mainTextureOffset = Vector2( valueX, valueY);

Then you want to randomize the offset between 0 and 1 : http://docs.unity3d.com/Documentation/ScriptReference/Random-value.html

 var valueX : float = Random.value;
 var valueY : float = Random.value;

Put it all together in a script on it's own, then attach it to the static object :

 function Update()
 {
     var valueX : float = Random.value;
     var valueY : float = Random.value;
  
     renderer.material.mainTextureOffset = Vector2( valueX, valueY );
 }

exactly the same as the OffsetMainTexture() function

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 Halo500 · May 13, 2013 at 03:59 AM 0
Share

Lol, again, sorry for my lack of knowledge on all of this. I have actually gotten a lot more familiarized with Unity in just a few weeks, a lot thanks to you alucardj. I have opened the door. xD

I also created my main menu, the credits page, and many more scenes thanks to your old videos and I have given you many thanks in the credits scene.

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

15 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

Related Questions

Read Y offset value of a Texture 1 Answer

Assigning UV Map to model at runtime 0 Answers

how to define a static texture2D? 2 Answers

Options not showing (noob question) 1 Answer

How Can I Make Materials Keep The Same Global Offset On Different 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