//moves without checkingColisions public static PhysicTransform Move(PhysicTransform tranform, Vector2 acceleration, float deltaTime) { Vector2 previousAcceleration = acceleration; tranform.velocity += acceleration; tranform.position += (tranform.velocity + gravity * Vector2.down) * deltaTime; tranform.velocity = Vector2.Lerp(previousAcceleration, tranform.velocity, dampening * deltaTime); return(tranform); }
//moves and checks for collisions public static PhysicTransform Move(PhysicTransform transform, BoxCollider2D collider2D, Vector2 acceleration, float deltaTime) { PhysicTransform transform2 = Move(transform, acceleration, deltaTime); //for each box collider in the level foreach (var levelCollider in gameState.levelColliders) { Vector2 diff; if (BoundsAreIntersecting(collider2D.bounds, levelCollider.bounds, out diff)) { Debug.Log("OMG CA COLLIDE"); transform.position += diff; break; } } return(transform); }
// Start is called before the first frame update void Start() { pTransform = new PhysicTransform(transform, mass, pType); PhysicManagerWrapper.instance.AddPhysEnity(pTransform); }