I’m facing a bit of a weird issue where moving horizontally creates a strange Y velocity on my character, but only on a tilemap collider. I have two videos to show the effect. Note the Y velocity number on the far right of the gifs:
On a standard Box Collider:
On my tilemap floor with a composite collider:
using a standard, flat box sprite, everything behaves as expected. On the tilemap, which I set up exactly as shown in the course, my character gains positive or negative Y velocity depending on which direction I move. What’s more, the direction that produces a positive or negative Y value in this case seems completely random, and depends on which direction I go first when playtesting. The value also seems to change arbitrarily after jumping or dropping off a ledge and continuing to run.
Nothing in my code for running around produces or alters the Y value in any case, it’s set up exactly as Rick did.
void Run()
{
Vector2 playerVelocity = new Vector2(moveInput.x * playerSpeed, rigid2d.velocity.y);
rigid2d.velocity = playerVelocity;
animator.SetBool("isRunning", Mathf.Abs(rigid2d.velocity.x) > Mathf.Epsilon);
}
While this doesn’t seem to have much of an effect on gameplay at the moment, it does mess with my falling animation, which triggers when velocity.y < Mathf.Epsilon. Anyone have an idea what causes this, or how to fix it?