DevLog - Day 6
When a passenger is picked up a voice is played, I used a tts site to generate some voices, in case I didn't have time to record them.
I finished off creating the other characters: there are now 30 passengers.
I was keen to create a NPC car controller that was able to drive itself, or at least one that used the rigidbody and physics forces; I watched a video by codemonkey that would've been helpful. I made a very quick attempt, but unfortunately due to the lack of time I don't think I've got the dev time to finish it.
So instead I decided to just create bunch of series' of waypoints. The cars will then move from one waypoint to another. The car 3d models and speed will randomly vary on start. For simplicity the cars can not hit each other.
I've created 4 paths: 4 + 8 + 7 + 10 cars each, for a total of 29 cars in the town driving around
I added a horn sound when the F button is pressed and pressing G will toggle the headlights. No reason just because I can.
At one point I hit a car and my car fell through the ground, so I added a Z check, if it's below 0 it'll move the car into the air. I've not encountered the bug again, so I haven't been able to test this code.
I also had a bug where I hit a fence and got stuck. So now pressing R will reset the car to a safe position.
I added health and now the car will take 5 damage from hitting other cars and 1 damage from hitting anything else. The car can be repaired from the shop. I also added a game over window for when the player has no health and the cars input will be disabled.
I created a "text on the ground" prefab, to show how much money a taxi ride has earned the player. Adding this made a big difference in the communication feedback and satisfaction of the ride.
![]() | ![]() |
When target dropped off shows cash earned | When player hits something, shows damage taken in red |
It has an icon (currently only used for a dollar note), it uses a canvas group to allow the fading out.
using System.Collections;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class GroundText : MonoBehaviour
{
public CanvasGroup canvasGroup;
public TextMeshProUGUI txtAmount;
public Image img;
public void Show(string amount, float fadeDuration, bool showImage = false, Color? txtColor = null)
{
txtAmount.text = amount;
txtAmount.color = txtColor ?? Color.white;
if (img != null)
{
if (showImage)
img.gameObject.SetActive(true);
else
img.gameObject.SetActive(false);
}
StartCoroutine(Fade(1f, 0f, fadeDuration));
}
IEnumerator Fade(float startValue, float endValue, float duration)
{
float time = 0;
while (time < duration)
{
canvasGroup.alpha = Mathf.Lerp(startValue, endValue, time / duration);
time += Time.deltaTime;
yield return null;
}
canvasGroup.alpha = endValue; // Ensure final value is set
}
}
Finally I created a simple MusicManager. It has a list of songs and upon startup it'll choose one randomly and play it in a loop.
public class MusicManager : MonoBehaviour
{
AudioSource audioSource;
public AudioClip[] music;
void Start()
{
audioSource = GetComponent<audiosource>();
// choose a random tune
int musicIx = Random.Range(0, music.Length);
audioSource.clip = music[musicIx];
// play it
audioSource.Play();
}
void Update()
{
}
}
</audiosource>
Files
TinyTown
TinyWorld game made for a GameJam
More posts
- Post mortem9 days ago
- Resources10 days ago
- Dev Log - Day 512 days ago
- Pickup and drop off - Day 412 days ago
- Building a Town - Day 314 days ago
- Car Controller - Day 215 days ago
- First Entry - Research16 days ago
Leave a comment
Log in with itch.io to leave a comment.