private void Collision() { Vector2 posPlus = transform.position; posPlus += GetDown() * Time.deltaTime; Block what = DoCollisions.WhatHit(posPlus, transform.localScale, -transform.rotation.eulerAngles.z * Mathf.Deg2Rad); switch (what) { case Block.GROUND: if (!hitD) { hitD = true; upVelocity = 0; gacc = 0; } SnapToGround(); break; default: hitD = false; gacc += GRAVITY * Time.deltaTime; break; } }
private void SnapToGround() { Vector3 pos; Vector2 posPlus = transform.position; //posPlus += (-upVelocity + GRAVITY) * GetDown() * Time.deltaTime; pos = DoCollisions.ContactPoint(posPlus, transform.localScale, -transform.rotation.eulerAngles.z * Mathf.Deg2Rad); transform.position = new Vector3(pos.x, pos.y, transform.position.z); }