- Home /
Translate.transform problems (collision/Rigibody)
Hello!
I have a problem my player stopps moving when collide with the border of two surfaces (in orange). How do I fix it?
Problem description
The player moves slowly faster like it should be. But as soon as it leaves one surface to enter another (show screenshot) it suddenly stops moving and it won't move or rotate anymore. It only rotates or moves if I drag and drop it again (x,y,z).
What components do I use?
I use a default Box Collider with a default Rigidboy. Settings are default settings.
My code:
if (h1 != 0 || v1 != 0)
transform.localEulerAngles = new Vector3(0f, Mathf.Atan2(v1, h1) * 180 / Mathf.PI, 0f);
__animator.SetFloat("Speed", SpeedMultiplier);
__animator.speed = (SpeedMultiplier > 1.5f) ? __animator.speed = SpeedMultiplier : 1.0f;
if (v1 < -0.001f && IsGrounded)
{
transform.Translate(transform.right * .5f * SpeedMultiplier, Space.Self);
}
if (v1 > 0.001f && IsGrounded)
{
transform.Translate(-transform.right * .5f * SpeedMultiplier, Space.Self);
}
if (h1 < -0.001f && IsGrounded)
{
transform.Translate(-transform.forward * .5f * SpeedMultiplier, Space.Self);
}
if (h1 > 0.001f && IsGrounded)
{
transform.Translate(transform.forward * .5f * SpeedMultiplier, Space.Self);
}
if (SpeedMultiplier < MaxSpeedLimitation && (v1 != 0 || h1 != 0))
SpeedMultiplier += 0.02f;
if (SpeedMultiplier > 1 && v1 == 0 && h1 == 0)
SpeedMultiplier -= 0.5f;
Your answer
Follow this Question
Related Questions
Trouble with Physics.IgnoreCollision 0 Answers
Rotating child doesn't move parent Rigidbody? 1 Answer
How to keep a Gameobject in the same position after a transform.Rotate? 2 Answers
Procedual Collider is not working correctly - Until reset in editor C# 0 Answers
C# always move an object forward and still use physics 1 Answer