You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi guys,
There was an issue I had where going over the edge of a peak on an angle platform causes you to jitter as it figures out where the collision occurs. As one ray goes over the edge the player drops until a suitable collision occurs as shown in this image
I set out to solve this without increasing the number of rays cast down and decided on a compromise that isn't exactly elegant but it largely solves the problem.
My idea was that it only occurs in a small area so I could cast a ray horizontally across the bottom of the player then use the collision from that to cast one more ray downwards to create collisions. This adds two more ray calculations and makes far smoother situations in this case.
The following code was added to the Controller2D.cs script, at the top of the VerticalCollisions method.
Note that I also took the creation of rayOrigin and hit out of the for loop.
Hi guys,
There was an issue I had where going over the edge of a peak on an angle platform causes you to jitter as it figures out where the collision occurs. As one ray goes over the edge the player drops until a suitable collision occurs as shown in this image
I set out to solve this without increasing the number of rays cast down and decided on a compromise that isn't exactly elegant but it largely solves the problem.
My idea was that it only occurs in a small area so I could cast a ray horizontally across the bottom of the player then use the collision from that to cast one more ray downwards to create collisions. This adds two more ray calculations and makes far smoother situations in this case.
The following code was added to the Controller2D.cs script, at the top of the VerticalCollisions method.
Note that I also took the creation of rayOrigin and hit out of the for loop.
`
Vector2 rayOrigin = raycastOrigins.bottomLeft + new Vector2(skinWidth, -skinWidth);
float horRayLength = Vector2.Distance(raycastOrigins.bottomRight, raycastOrigins.bottomLeft) - (skinWidth * 2);
RaycastHit2D hit = Physics2D.Raycast(rayOrigin, Vector2.right, horRayLength, collisionMask);
`
If anybody has a cleaner solution to this or needs it explained better, let me know
The text was updated successfully, but these errors were encountered: