- Home /
Question by
gararules112 · May 26, 2018 at 03:15 AM ·
glitchmovepositionglitching
Moveposition randomly "jumps"
So i am using a code that moves my character along the X axis. It works perfect on my movements but randomly when i am moving it my player feels like he jumps kind of, if that makes sense...
If it doesn't the player is moving then randomly is and isnt where he was before. don't know why it's happening. just need some help figuring it out.
here is my movement code for reference:
private Rigidbody PlayerRB;
public float movespeed = 20f;
private float XAxis;
public float Edges = 7f;
void Start ()
{
PlayerRB = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update ()
{
XAxis = Input.GetAxis("Horizontal") * Time.deltaTime * movespeed;
Vector3 Clamp = PlayerRB.position + Vector3.right * XAxis;
Clamp.x = Mathf.Clamp(Clamp.x, -Edges, Edges);
PlayerRB.MovePosition(Clamp);
}
Comment
Your answer
Follow this Question
Related Questions
Weird double-tap bug when I use standart controller (Android) 0 Answers
Glitches in IOS build but not in android build 1 Answer
glitching player 0 Answers
Black Areas in Terrain 0 Answers