Hello everybody,
I am kinda new to the unity editor for making games (used it mainly for machine learning up until now) and I don’t understand how come what is happening is happening.
It seems like there is a bug with the unity tilemap 2D collider or there is something I clearly don’t understand
It is a rather complicated thing to explain so I’ll post a video so you can see the problem
I am not changing the transform.position of my character via script nor am I touching to colliders.
Also, I’ve been having a lot of clipping through textures and popping back to the top, is it normal / should I use something else or did I mess up ?
Thanks in advance for your help !
Here is the script for my player
public class Player : MonoBehaviour
{
public float speed = 0.12f;
public float y;
public float z;
public float jump_force;
public bool jumping;
Rigidbody2D rb;
void Start()
{
rb = GetComponent<Rigidbody2D>();
jumping = false;
}
void FixedUpdate()
{
transform.Translate(Input.GetAxis("Horizontal") * speed, y, z);
//CANT GET LEFT OF THE MAP
/*if (transform.position.x < -11)
{
transform.position = new Vector3(-11, transform.position.y, transform.position.z);
}*/
}
private void Update()
{
if (Input.GetAxis("Horizontal") < 0)
{
transform.localScale = new Vector3(-1,1,1);
} else if (Input.GetAxis("Horizontal") > 0)
{
transform.localScale = new Vector3(1, 1, 1);
}
if (Input.GetKeyDown(KeyCode.UpArrow) && !jumping)
{
rb.AddForce(transform.up * jump_force, ForceMode2D.Impulse);
jumping = true;
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Ground"))
{
jumping = false;
}
}
}