301 Days (redux)

Another metric leap year of gamedev experiments and such

Day 23 - Finally back to normal NPCs

Sep 29, 2015 - 2 minute read - OldDaysste-reez-muvi

Finishing bringing the NPCs into the new CellLoc reality.

Happy (Inter)National Coffee Day! Happy (Inter)National Coffee Day!

NPCs back to what passes for normal

To get the multiple NPCs to fill in top-left to bottom-right, had to change the y-position calc a bit:

Assets/lib/CellLoc.cs GitLab
34
35
36
37
38
39
40
41
42
43
44
45
46
} else {
    Vector3 position;
    int xPos = c.idx % c.dim;
    int yPos = c.idx / c.dim;
    position.x = c.x - 0.5f; // left side
    position.x += (1f / (c.dim * 2f)); // first position
    position.x += xPos * (1f / c.dim);
    position.y = (-1f) * c.y + 0.5f; // top side
    position.y -= (1f / (c.dim * 2f)); // first position
    position.y -= yPos * (1f / c.dim);
    position.z = (-0.1f) * (c.z + layer);
    return position;
}

To get the camera to the correct position looking in the right direction when we hit N:

Assets/Managers/GUIManager.cs GitLab
25
26
27
28
29
30
if (Input.GetKeyDown (KeyCode.N)) {
    CellLoc randomNpcCell = npcManager.locateRandomNpc();
    Vector3 randomNpcPos = CLUtils.CellLocToVector3(randomNpcCell, 1);
    mainCamera.lookAtNpc(randomNpcPos);
    mapManager.UpdateZ(randomNpcCell.z);
}
Assets/CameraControlScript.cs GitLab
95
96
97
98
public void lookAtNpc(Vector3 npcPos) {
    transform.position = new Vector3(npcPos.x, npcPos.y, npcPos.z - 15f);
    transform.LookAt(npcPos);
}

We also cached the Renderer and negated all of the z-offsets in NpcScript, and flipped the arrow image we’re using for hatred. Good enough?

All that to just get back to looking like this. All that to just get back to looking like this.

Another short one today. Tomorrow we’ll do something about this:

Need to even this out before we can add more stuff to do. Need to even this out before we can add more stuff to do.

More to come

Day 23 code - visualizer