- Home /
Question by
Jasmin1347 · Jul 28, 2018 at 11:18 AM ·
movement scriptaxisplayer movementshakeposition
player is shake up-down?
my player is shake when it reach 100 position on y axis,i mean it was going to 101 and 100 postion(up down) continuously.Here my script.
temppos = transform.position;
if (temppos.y > 100f && temppos.y < 110f) {
temppos.y = Mathf.Clamp (temppos.y, -maximum_up, maximum_up);
//temppos.y = 100f;
transform.position = temppos;
}
if (_slider.value > 3f) {
if (transform.position.y < maximum_up) {
if (transform.rotation != Quaternion.Euler (0, 0, 0)) {
transform.localPosition += transform.up * Time.deltaTime * _slider.value * forward_speed;
} else {
transform.localPosition += transform.up * Time.deltaTime * _slider.value;
}
} else
{
if (transform.rotation.eulerAngles.x > 100f) {
transform.localPosition += transform.up * Time.deltaTime * _slider.value * forward_speed;
}
else if (transform.rotation.eulerAngles.x > -100f && transform.rotation.eulerAngles.x < -80f) {
transform.localPosition += transform.up * Time.deltaTime * _slider.value * forward_speed;
}
else if (transform.rotation.eulerAngles.z > 100f) {
transform.localPosition += transform.up * Time.deltaTime * _slider.value * forward_speed;
}
else if (transform.rotation.eulerAngles.z > -100f && transform.rotation.eulerAngles.z < -80f)
{
transform.localPosition += transform.up * Time.deltaTime * _slider.value * forward_speed;
}
}
}
Maximumup = 100;
Comment
You're probably changing the position after clamping it in this if: (This is the if for clamping the pos)
if (temppos.y > 100f && temppos.y < 110f) {
temppos.y = $$anonymous$$athf.Clamp (temppos.y, -maximum_up, maximum_up);
//temppos.y = 100f;
transform.position = temppos;
}
You should move that ^ if to the end of your script |