Hi All,
This is probably user error on my end, but I am running into the following issue. I created a Tile Palette with some basic “Land” components. I have a “Steep Slope” ground, both oriented going left & right. For some reason, my character is not registering the tile slope components that are angled up and left, but can register the up and right just fine. I attached an image!
It has to do with grounding (the character is not picking up that they are grounded when running on the one to the left, but does pick up they are grounded when running up the slope to the right. As a result, gravity drags the character down the slope on the left.
I checked to see if there are colliders on the tiles, and there are. They are the same layer, and the rays used to check for grounding are checking for that layer.
My grounding code is below - please note that the red lines on the image above are the rays used for grounding! I’m a relatively novice coder, so apologies in advance!
public void checkGrounding()
{
centerGroundingData = Physics2D.Raycast(centerGroundSensor.position, Vector2.down, Mathf.Infinity, discludePlayer);
rightGroundingData = Physics2D.Raycast(rightGroundSensor.position, Vector2.down, Mathf.Infinity, discludePlayer);
leftGroundingData = Physics2D.Raycast(leftGroundSensor.position, Vector2.down, Mathf.Infinity, discludePlayer);
if (centerGroundingData.distance - groundSensorDistance > 0 && rightGroundingData.distance - groundSensorDistance > 0 || leftGroundingData.distance - groundSensorDistance > 0 && centerGroundingData.distance - groundSensorDistance > 0)
{
if (isGrounded && gravityPullDelayTimer == 0) // this is specifically to prevent jittering when walking down or up slopes
{
gravityPullDelayTimer = gravityPullDelay;
}
else if (gravityPullDelayTimer > 0)
{
gravityPullDelayTimer -= Time.deltaTime;
}
else if (gravityPullDelayTimer < 0) {
gravityPullDelayTimer = 0;
isGrounded = false;
}
}
else
{
isGrounded = true;
}
}
I’m 98% sure it’s something I’m doing wrong, just don’t know how to proceed, any help would be appreciated!
Thanks!