简体   繁体   English

如何避免统一翻转健康栏

[英]How to avoid flipping health bar in unity

I am creating a platformer game in unity, but I have a weeny problem, my camera is flipping.我正在统一创建一个平台游戏,但我有一个小问题,我的相机正在翻转。 This causes flipping of every object, I attach to player (healthbar for instance), how to avoid this flipping?这会导致每个 object 的翻转,我附加到播放器(例如健康栏),如何避免这种翻转?

Im not really sure on what u are trying to do.我不太确定你想做什么。 But if i understand you correctly, try freezing the Z Axis on whatever is flipping但如果我理解正确,请尝试将 Z 轴冻结在任何翻转的位置

Oh I know what you want.哦,我知道你想要什么。 So you just have to clamp the value of the health bar.所以你只需要钳制健康条的值。 I'll show you an example with just the a float because I don't know what your code looks like.我将向您展示一个仅带有浮点数的示例,因为我不知道您的代码是什么样的。

float health = 100f;

void Update(){
     health = Mathf.Clamp(health, 0f, 100f);
}

Your value can't get lower than the second input, and can't go higher than your third input.您的值不能低于第二个输入,也不能 go 高于您的第三个输入。

[EDIT] By the way. [编辑]顺便说一句。 You better include code.你最好包含代码。 Maybe the code that edits the health bar.也许是编辑健康栏的代码。 Because you are not likely to get a good answer if you don't因为如果你不这样做,你就不可能得到一个好的答案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM