Horrible Collison 2D --
Hello! So, I am making a simple platformer with basic movement (left, right, up)... I have my player (16x16 res.) with movement.cs script, collider 2d and rigidbody with mass 1 and gravity 1.
but the collison is terrible! First it goes in floor collider and than it slowly goes back.
What should i do to make it better? I already tried scaling it up but it doesnt help.
Full Movement Script:
void Start() { rigid = gameObject.GetComponent<Rigidbody2D>(); } void Update () { isGrounded = Physics2D.OverlapCircle(groundCheck.position, radius,whatIsGround); if(Input.GetKey(KeyCode.A)) { if(-rigid.velocity.x <= speedLimit) { rigid.AddForce(Vector2.left * speed * Time.deltaTime); } //flip transform.localScale = new Vector2(-Mathf.Abs(transform.localScale.x), transform.localScale.y); } else if (Input.GetKey(KeyCode.D)) { if (rigid.velocity.x <= speedLimit) { rigid.AddForce(-Vector2.left * speed * Time.deltaTime); } //flip transform.localScale = new Vector2(Mathf.Abs(transform.localScale.x), transform.localScale.y); } if(Input.GetKeyDown(KeyCode.Space) && isGrounded) { rigid.velocity = new Vector2(rigid.velocity.x, jumpHeight); }
Thanks!
Someone should be able to answer this. This has to be a common problem. I guess you could consider moving this question to the help room an he see if it gets a wider audience...
Do you want the elasticity at all or do you want it to be an hard surface?
I cannot reproduce this. Do you see it on all collisions or just that platform? Can we get screen shots of the settings for the colliders/rigidbodies/etc?
I can't see anything obviously wrong and we're not attracting others to comment so we just have to go into basic diagnostic mode: start executing experiments in an attempt to narrow down the problem.
Experiments I can imagine:
Start turning off scripts - even ones that seem unimportant.
Start trying to reproduce this in a fresh project by copying what you think are the $$anonymous$$imal set of assets into it.
Build parallel objects to the ones that have a problem from scratch.
You know your game better than I do so it seems like you're going to be able to invent more experiments but I will say that one person I tried to help with an inexplicable-see$$anonymous$$g problem did actually find out that it was something to do with their project settings. I don't know if that person just copied everything into a new project or hunted down the setting that was the problem but even knowing that's what it was helped.
The moral of that story is don't rule anything out until you have empirically ruled it out of bounds.
Thanks! I"ll try experimenting... If I find out anything I will post an answer!
Answer by MaxGuernseyIII · Nov 04, 2017 at 05:06 AM
This is a wild guess but have you played with interpolation, at all? It seems like it's exactly for this and their recommendation was specifically to have it be turned on for the main character and off for everything else.
Already tried that... Both extra and interpolation... Same issue.
Your answer
Follow this Question
Related Questions
OnTriggerEnter2D and OnCollisionEnter2D not working 1 Answer
Tilemap Collider problems 0 Answers
Circle Collider2D Stuck ob Box Collider2D at the corner :( 0 Answers
Can't make the player attack an enemy 0 Answers
2D collision not working 0 Answers