You are on page 1of 6

C# LIBRARY

x *= 8 sama dengan x = x * 8
x /= 8 sama dengan x = x / 8
x -= 8 sama dengan x = x - 8

P => (Problem) Glitches Bouncing (Samping)

if (!collisions.climbingSlope || slopeAngle > maxClimbAngle) {


velocity.x = (hit.distance - skinWidth) * directionX;
rayLength = hit.distance;

collisions.left = directionX == -1;


collisions.right = directionX == 1;
}
A=> (Answer) Because we are not updating the velocity on Y Axis

S=> (Solution)
if (!collisions.climbingSlope || slopeAngle > maxClimbAngle) {
velocity.x = (hit.distance - skinWidth) * directionX;
rayLength = hit.distance;

if (collisions.climbingSlope) {
velocity.y = Mathf.Tan(collisions.slopeAngle * Mathf.Deg2Rad) *
Mathf.Abs(velocity.x);
}

collisions.left = directionX == -1;


collisions.right = directionX == 1;
}

P => Glitches Bouncing Top

if (hit) {
velocity.y = (hit.distance - skinWidth) * directionY;
rayLength = hit.distance;

collisions.below = directionY == -1;


collisions.above = directionY == 1;
}

A => Because we are not updating the velocity on X Axis

S =>

if (hit) {
velocity.y = (hit.distance - skinWidth) * directionY;
rayLength = hit.distance;

if (collisions.climbingSlope) {
velocity.x = velocity.y / Mathf.Tan(collisions.slopeAngle * Mathf.Deg2Rad) *
Mathf.Sign(velocity.x);
}

collisions.below = directionY == -1;


collisions.above = directionY == 1;

P => Glitches went meet intersection between 2 Obstacles

if (collisions.climbingSlope) {
float directionX = Mathf.Sign(velocity.x);
rayLength = Mathf.Abs (velocity.x) + skinWidth;
Vector2 rayOrigin = ((directionX == -1)?raycastOrigins.bottomLeft:raycastOrigins.bottomRight) +
Vector2.up * velocity.y;
RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.right * directionX, rayLength, collisionMask);

S =>
if (collisions.climbingSlope) {
float directionX = Mathf.Sign(velocity.x);
rayLength = Mathf.Abs (velocity.x) + skinWidth;
Vector2 rayOrigin = ((directionX == -1)?
raycastOrigins.bottomLeft:raycastOrigins.bottomRight) + Vector2.up * velocity.y;
RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.right * directionX, rayLength,
collisionMask);

if (hit) {
float slopeAngle = Vector2.Angle(hit.normal,Vector2.up);
if (slopeAngle != collisions.slopeAngle) {
velocity.x = (hit.distance - skinWidth) * directionX;
collisions.slopeAngle = slopeAngle;
}

You might also like