Please help me! Correct script) ,
Помогите плиз. При нажатии на гуи кнопку должна подниматься/опускаться подвеска,но она при достижении макс позиции почему-то подымается дальше до бесконечности. Как сделать так, чтоб при достижении значения, подвеска подымалась,опускалась например на 0.02F.
Help me pliz. When you press the button, the button should raise / lower the suspension, but when it reaches the max position for some reason it rises further indefinitely. How to make it so that when the value is reached, the suspension rises, fell for example to 0.02F.
using System.Collections; using System.Collections.Generic; using UnityEngine; [ExecuteInEditMode] public class podveska : MonoBehaviour {
public void buttonPressed(){
{
transform.position += new Vector3(Mathf.Clamp(Vector3.up.x, 0.0F, 0.02F),Mathf.Clamp(Vector3.up.y, 0.0F, 0.02F),Mathf.Clamp(Vector3.up.z, 0.0F, 0.02F));
if(transform.position.y > 0.08)
{
transform.position += new Vector3(Mathf.Clamp(Vector3.down.x, 0.0F, 0.04F),Mathf.Clamp(Vector3.down.y, 0.0F, 0.04F),Mathf.Clamp(Vector3.down.z, 0.0F, 0.04F));
}
}
}
},
Your answer
Follow this Question
Related Questions
I can not modify localscale while I'm playing because of the Animator. 1 Answer
Position Child Object to center of Parent Object [SOLVED] 1 Answer
Problem. Pick up and Grab object script, except all objects in scene are picked up instead of one. 0 Answers
Camera isn't move position? Why my camera isn't change position? 0 Answers