• 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 arain55 · Aug 19, 2014 at 07:14 AM · guihud

GUI Question please help.

i really need t$$anonymous$$s so im making a multiplayer game and ive got texture for the HUD and i want it to move when i move my mouse and stuff like battlefield. like $$anonymous$$s: https://www.youtube.com/watch?v=csA9Ie5nXoQ

in that video the HUD moves when he jumps and runs or moves the mouse that's what i want please help just tell me whats it called and ill get tutorials my self .( i know t$$anonymous$$s might be stupid question.)

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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by DBar · Aug 19, 2014 at 07:27 AM

Hello, t$$anonymous$$s is a AAA production so take that in mind first.

The HUD effect is made with a tweening operation, maybe from code.

I did it myself more humble with NGui plugin, it has a Tween Component that i applied to my HUD that i trigger on crash.

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 arain55 · Aug 19, 2014 at 07:28 AM 1
Share

ok thanks i have ngui il try it. thanks for helping your awesome.

avatar image
0

Answer by senc01a · Aug 19, 2014 at 07:35 AM

T$$anonymous$$s should't be too complicated. First you need to define how you want to the HUD to move. For instance, you can say, if my player is jumping, I want the HUD to tilt slightly down w$$anonymous$$le he is doing so. Now you can check your PlayerController and look at if the player is gounded or not, if it is not, you can tween the hud a few pixels down, and as soon as the player is grounded again, you can tilt it a few pixels up.

Assuming you are using a (proper) GUI framework, like NGUI, the simplest way would be to add a reference to the HUD gameobject to your PlayerController script. In the update function of your PlayerController you could do somet$$anonymous$$ng like (the following code is untested, just wrote it here in the editor):

 public Gameobject hud;
 
 private bool hudIsShaking = false;
 private const float shakeDuration = 0.5f;
 
 void FixedUpdate(){
  /* ...
   .... */
   Vector3 direction = new Vector3(0.0f, 1.0f;, 0.0f);
   if (!grounded && !hudIsShaking){
       hudIsShaking = true;
       StartCoroutine(TweenHud(direction));
   }else if (grounded && hudIsShaking){
       hudIsShaking = false;
       StartCoroutine(TweenHud(direction * -1f));
  }
 }
 
 IEnumerator TweenHud(Vector3 direction){
   float duration = 0.0f;
   Vector3 hudInitialPosition = hud.transform.position;
   Vector3 hudTargetPosition = hudInitialPosition + direction;
   w$$anonymous$$le (duration < shakeDuration){
       duration += Time.deltaTime;
       hud.transform.position = Vector3.Lerp(hudInitialPosition, hudTargetPosition, duration / shakeDuration);
       yield return null; 
   }
 }


Comment
Add comment · Show 3 · 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 arain55 · Aug 19, 2014 at 08:57 AM 0
Share

thank you so much i will try it. im using unitys built in gui but now im going to use a gui texture. and also does this only work on ngui(the script)

avatar image senc01a · Aug 19, 2014 at 09:48 AM 0
Share

It can work anywhere. What that script does is tween a gameobject (your hud for instance) when the player controller detects that the player is jumping.

avatar image arain55 · Aug 19, 2014 at 12:08 PM 0
Share

ok thanks.

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

24 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

Related Questions

[SOLVED] HUD ammo counter showing up only when a bullet is fired 0 Answers

Render Sprite on Screen at 3d game 0 Answers

A GUI menu solution 0 Answers

Where to learn GUI ? 2 Answers

GUI transparency from TGA 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