Skip to main content
Added an explanatory image
Source Link

I'm presently trying to do a sorta Starfox clone with Raylib, using the heightmap example here: https://www.raylib.com/examples/models/loader.html?name=models_heightmap

In order to handle collision in this environment, I think we need to check the player's current height against the grey value of the current pixel the craft is within. If the grey value of the currently 'occupied' ground pixel is 'higher' than the player's current Y, then the plane is currently touching the ground and has crashed.

Heightmap Illustration In my illustration, we'll assume that if the player is at the height level indicated by C05 in that box, then they're in contact with the ground and is crashing. However, if the player is at the height of total white while positioned on a black square (XZ), eg. B04, then they're high over the canyon and not colliding.

I can't seem to work out how to identify the right pixel in the heightmap to match the player's position from within Raylib - does anybody know how to extract that info?

I'm presently trying to do a sorta Starfox clone with Raylib, using the heightmap example here: https://www.raylib.com/examples/models/loader.html?name=models_heightmap

In order to handle collision in this environment, I think we need to check the player's current height against the grey value of the current pixel the craft is within. If the grey value of the currently 'occupied' ground pixel is 'higher' than the player's current Y, then the plane is currently touching the ground and has crashed.

I can't seem to work out how to identify the right pixel in the heightmap to match the player's position - does anybody know how to extract that info?

I'm presently trying to do a sorta Starfox clone with Raylib, using the heightmap example here: https://www.raylib.com/examples/models/loader.html?name=models_heightmap

In order to handle collision in this environment, I think we need to check the player's current height against the grey value of the current pixel the craft is within. If the grey value of the currently 'occupied' ground pixel is 'higher' than the player's current Y, then the plane is currently touching the ground and has crashed.

Heightmap Illustration In my illustration, we'll assume that if the player is at the height level indicated by C05 in that box, then they're in contact with the ground and is crashing. However, if the player is at the height of total white while positioned on a black square (XZ), eg. B04, then they're high over the canyon and not colliding.

I can't seem to work out how to identify the right pixel in the heightmap to match the player's position from within Raylib - does anybody know how to extract that info?

Source Link

How do I get a 3D collision with a Heightmap in Raylib?

I'm presently trying to do a sorta Starfox clone with Raylib, using the heightmap example here: https://www.raylib.com/examples/models/loader.html?name=models_heightmap

In order to handle collision in this environment, I think we need to check the player's current height against the grey value of the current pixel the craft is within. If the grey value of the currently 'occupied' ground pixel is 'higher' than the player's current Y, then the plane is currently touching the ground and has crashed.

I can't seem to work out how to identify the right pixel in the heightmap to match the player's position - does anybody know how to extract that info?