Collisions and doors
Collisions and doors
Part 7
In this part we will be covering collisions and doors
Collision mesh needs to be simple anything too complex and the npc's will get stuck, boxes work well for this so lets start with a wall
Before we start we need to move the waypoint inside the lobby because this is where we spawn and after doing the collisions we cant get back in
We can also hide objects in the scene to make this easier
Select the celing and go display > hide > hide selected to unhide do the same display > show > show selected
Now draw a box around the wall it does not have to be perfect because we can edit it
Next hold right click on the box and chose face then align the faces with the wall make sure they cover it
Do the same with all walls and furniture leaving gaps for the doorways
The 2 doorways in the corridor can be covered up with collision because we are not using them but the last one is the exit (which we wont use here anyway so up to you)
Make sure you do not do the floor, roof or tops of doorways
This is because the ai's nav paths use a 2d mask of sorts white is where they can walk and black is where they cant so if you add a collision on the top of a doorway they cant walk across the line
Looking at this collision I missed a bedroom wall
EDIT i forgot to mention how to actually make them collisions sorry bout that
In the scene.ini
rb "ColShape1" { physics { elem[0] {mesh = "ColShape1";} elem[1] {mesh = "ColShape2";} elem[2] {mesh = "ColShape3";}
add the required amount of elem as required
Sick of writing out the collisions
elem[121] {mesh = "ColShape122";} yea me too
Floors are done by using
rb "ColShape118" { render {}//render is optional physics { shape_type = GROUND_FULL; coll_type = NONE; } }
The diffrence is npcs can only walk on GROUND_FULL and if you do have gaps in the floor non GROUND_FULL collisions can create edges that the player will get stuck on
Now onto doors
Doors are easy to make when you get the pivot point right and not half way across the map because then you spend hours screaming and crying because it does not work
So make sure the pivot point for the door is where it would rotate from up and down does not matter
To move the pivot first go select the door and go modify then centre pivot then hold d and move the pivot point
After the pivot is in the right location we need to give it a collision box
So make a box around the door leaving room around the sides and top
Name the collision box something like "FrontDoorColl"
Then in our scene.ini add this in above the collision meshes
rb "FrontDoorShape" { link { type = REVOL; // Revolving door axis0 = Y; // Revolving axis axis1 = Z; // Opposite axis Fc = 0.5; // Friction kd = 0.5; // Damping Ks = 1; // Spring (so it closes) Ls = 0.0; // Spring angle } render {} physics { elem[0] { mesh = "FrontDoorCollShape"; } } interact {} // Can open door by hand }
And now we need to do one more
Open up pack_tutorial\init\stories\tutorial\scenes tutorial.dat
We need to add this in after the first closing bracket
door_objecti DOOR1 { q = 0; q_min = -360; q_max = 360; q_spring = 0.1; open = true; obj_name = "FrontDoor"; }
This part explains what each one does
door_objecti DOOR1//--- Door object and its own unique name q = 0; //---- Where the door will sit at default q_min = -360;//---- How far the door will open one way q_max = 360;//---- How far the door will open the other way q_spring = 0.1;//---- How quickly the door will auto close 0 is none open = true;//---- If the door is locked or not false it wont move obj_name = "FrontDoor";//---- First name of the object in the scene and it also must be referenced as an Rb in the scene.ini like we just did
Now save the scene, scene.ini and tutorial.bat Then run the filemaker and see the door ingame
Nice happy swinging door
Next do the same with all the doors except the 2 in the hallway since they don’t open there is no need
If the door only opens part way and kinda wobbles a bit its because the collision boxes are fighting so just move the wall collision a bit back to let the door pass
Part 8 just wet its self a little