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 sevensixtytwo · Sep 05, 2014 at 03:52 PM · cameraguitextureoverlay

Cylindrical GUITexture Overlay

I'm making an tank-heavy game and one of the mechanics is for the player to be able to button up the hatch. I'd rather not model specific tank interiors since I plan on having more than 1 playable tank so I was thinking of using the periscopes in a similar manner to M1 Tank Platoon 2.

Periscopes!

It probably isn't that obvious in the picture, but it is a 2D Texture that wraps around the camera. The overlay maintains a rotation that is relative to the turret and not the viewport. This lets the player look 360 degrees without encountering the end of the overlay, essentially forming the inside of a cylinder.

So, my question is: How would one implement this cylindrically scrolling overlay that rotates relative to a gameObject (the turret). I am already able to stitch full-screen GUITextures together, but I haven't yet been able to make them wrap around the camera nor rotate relative to the turret.

I use MouseLook.cs to rotate the camera.

UPDATE: Okay, maybe my explanation above was a bit too confusing.

There's a periscope at every 45th degree for a total of 8 periscopes. Each periscope is actually a separate GUITexture that is a child of a GameObject that moves along the X-axis in relation to mouseInput.

Supposedly this should give the player 360 degree vision, but as you can see, the overlay simply ends when going past 360 degrees. How would I be able to attach both ends of the GUITextures together so that it never ends (barring stitching on a carpload of GUITextures)?

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 sevensixtytwo · Sep 08, 2014 at 01:17 AM 0
Share

Please? Anyone? :(

1 Reply

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

Answer by sevensixtytwo · Sep 08, 2014 at 08:59 AM

Haha, okay. So I finally got past this little hurdle.

Instead of using a GUITexture, I used a childed quad placed 0.1 units in front of my camera. The quad had a Text Shader material containing the overlay. Then, I use this nifty piece of code I found on another answer...

 var v3ViewPort : Vector3 = new Vector3(0,0,quad.localPosition.z);
     var v3BottomLeft : Vector3 = Camera.main.ViewportToWorldPoint(v3ViewPort);
     v3ViewPort.Set(1,1,quad.localPosition.z);
     var v3TopRight : Vector3 = Camera.main.ViewportToWorldPoint(v3ViewPort);
     quad.localScale = new Vector3(v3BottomLeft.x-v3TopRight.x,v3BottomLeft.y-v3TopRight.y,quad.localPosition.z);

...in order to make the quad fit the Camera's aspect ratio. This is called at Start. Then used this...

 quad.renderer.material.mainTextureOffset = Vector2(-Camera.main.GetComponent(MouseLook).rotationX/45,-Camera.main.GetComponent(MouseLook).rotationY/45);

to rotate it. The "45" part governs how many times the texture repeats in 360 degrees, ie. each texture is 45 degrees, making it repeat 8 times in a 360 degree turn. Same goes for the Y-axis.

Here's how it looks in game:

https://dl.dropboxusercontent.com/u/282973338/WebBuild/WebBuild.html

Just press 3 on the keyboard to close the hatch. Other positions are still heavily WIP (can't fire MG, etc).

Comment
Add comment · 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

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

22 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

Related Questions

How to display multiple textures over the camera? 1 Answer

Weird Behaviour WebCamTexture to GUITexture 0 Answers

Instantiated GuiTextures not showing 1 Answer

Build iOS Screen Shot function using Unity 0 Answers

How to draw a Gui.Layer to a especific camera. 0 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