- Home /
Scale helmet to head size
Hi,
I am currently using many different characters in my game. Every character should be able to wear helmets. Is there some way to automatically scale the helmet untill the helmet fits on the head?
A scale overlap function, for example.
What method should one use to achieve the result?
Answer by zharik86 · Nov 26, 2014 at 07:43 PM
The easiest way, it to create a script and to attach it to your "helmet". The example of a script is lower:
//For example, each character have id
public void myScale(int numCharacter) {
if (numCharacter == 1) {
this.transform.localScale = (0.9f, 0.9f, 0.9f);
} else if (NumCharacter == 2) {
this.transform.localScale = (0.8f, 0.8f, 0.8f);
}
//And etc
}
And call this function how you dress your helmet. I hope that it will help you.
This is a solution, but I would like to write a function that returns the scale I am looking for automatically.
To be honest manually storing transform values like this is probably the most reliable and practical solution. I would probably store character head sizes in a script ins$$anonymous$$d so multiple helmets can adapt.
It may not seem that sophisticated but you could potentially waste a lot of time trying to automate something that may not be 100% effective.
Can't really think of anything that would single out the head size. $$anonymous$$aybe collisions or something in the $$anonymous$$esh class; $$anonymous$$esh.Bounds? Sounds like a lot of head scratching
Your answer
Follow this Question
Related Questions
change gameobjects size/scale acording to screen width? 0 Answers
Is there a way to disable Unity changing the texture scaling when using multiple materials 0 Answers
Scaling a Gameobject down alot makes the material black 3 Answers
Canvas Scaler settings 0 Answers
Scale using accelerometer with limits 0 Answers