- Home /
How can I make a textured power bar
Hi everyone,
It's a 3D game in top view (without gravity), it consists to launch a projectile from a position A, the final position of the mouse give the second point B, the vector AB is the direction of the launch and the magnitude of the vector is proportional to the power of launch.
My problem is graphic, I tried to do a textured power bar to the position of the mouse but the texture stretches and compresses depending on the size of the bar. This is a picture to be more clear
So it's possible to make it like the second picture?
Is this an actual object or some form of GUI? If it is an object you could try changing the 'tiling' of its material to be same as the scale, so when your object is at scale 1, your texture is also scale one, at object scale 0.5, you have have 0.5 as your tiling. If it is an OnGUI setup, you can use GUI groups.
You may also wish to check out Eric's pretty famous answer for making a circular progress bar
Answer by TrollHachem · Sep 11, 2014 at 03:55 PM
If you're using the 4.6 Open Beta uGUI , you can make the image component's image type filled and set it to horizontal , then simply clamp your health from 0 to 1 and put the result in "Fill Amount". If you're using legacy , well i don't know :/
Answer by R3K · Sep 13, 2014 at 07:56 PM
Thanks for the reply
I used a cylinder for my power bar, and I applied this script to control its "y" tiling proportionaly to the scale of my bar :
renderer.material.mainTextureScale = new Vector2 (1, AB.magnitude);
a little picture to illustrate the result
Your answer
Follow this Question
Related Questions
"Launch" a rigidbody 3 Answers
Creating a "drop zone" for textures 1 Answer
Limit object rotation on drag it 0 Answers
Dragging an object smoothly 2 Answers
Need help debugging: SiblingIndex 0 Answers