So just add a ridgidBody to my character and box colliders to the walls?I am making a Unity game and I am using Visual Studio to code. I am using a Character Controller to move the character, so how do I prevent the character from walking through walls?
Yeah pretty muchSo just add a ridgidBody to my character and box colliders to the walls?
Yeah pretty much
public enum Place { Solid, Air, Water }
//
private byte[,] levelPoints = new byte[2400, 600];
SetRect(0, 0, 2400, 500, (byte)Place.Air);
SetRect(0, 500, 2400, 600, (byte)Place.Solid);
//
private void SetRect(int x1, int y1, int x2, int y2, byte attribute)
{
for (int x = x1; x < x2; x++)
for (int y = y1; y < y2; y++)
levelPoints[x, y] = attribute;
}
public bool Wall()
{
if (levelPoints[player.X + player.Width, player.Y] == (byte)Place.Solid
|| levelPoints[player.X + player.Width, player.Y + player.Height / 2] == (byte)Place.Solid
|| levelPoints[player.X + player.Width, player.Y + player.Height] == (byte)Place.Solid)
return true;
return false;
}