🐉
Portfolio
  • Portfolio Jay Fairouz
  • Introduction Week
  • XR Concepting and Design
    • Concepting and Design Summary
    • XR Concept and iteration
    • Brown boxing
    • White boxing
    • Inspark
    • Shoeby
    • Specialisten Net
    • Walking Design
    • Multiple people in one body room
    • Environment
    • Echolocation Room
    • Portals
  • XR Assets
    • XR Assets
    • Temple Owl Logo
    • Platforms
    • Animating a moth
    • Color palette Echocave
  • XR Development
    • Development Summary
    • Dragon Race VR Development
    • Audio Visualizing
    • Walking Development
    • Glass Beads
    • Inhabit mechanic
    • Waterfall
    • Path creation
    • Learn someone how to program
    • Voice input mechanics
    • Paint
    • Portals
  • XR Testing
    • Dragon Race VR Testing
    • XR Testing
  • Group Process
    • Company Pitches
    • Sprint 1
    • Sprint 2
    • Sprint 3
    • Sprint 4
    • Sprint 5 and project conclussion
    • Project Goal
Powered by GitBook
On this page
  • Fire particles
  • Fixing the rotation

Was this helpful?

  1. XR Development

Voice input mechanics

PreviousLearn someone how to programNextPaint

Last updated 3 years ago

Was this helpful?

Previously I ported over the function that allowed us to get the user their voice volume and several mechanics that made use of that volume. Now I adjusted the rotation mechanic and added support for a flame that gets bigger/smaller depending on voice volume.

Fire particles

I wanted to create a particle effect that looked like fire and manipulate the size of the fire with the user their voice.

The second step was manipulating several particleSystem values through a script. I wanted to modify the emissionRate so more/less particles were created. ParticleScale so the particles would be bigger with a louder voice and particleLifeTime so that the bigger particles would also be alive longer which would mean that they reached a higher altitude.

    private void Start()
    {
        ps = GetComponent<ParticleSystem>();
        psMain = ps.main;
        psEmission = ps.emission;
        baseLifeTime = psMain.startLifetime.constant / 16f;
        baseSize = particleScale / 16f;
    }

    // Update is called once per frame
    void Update()
    {
        ChangeParticleEmmision();
    }

    private void ChangeParticleEmmision()
    {
        float volume = GetVolume();
        if (debugMode)
            volume = debugVolumeValue;

        psEmission.rateOverTime = (int)Mathf.Round(volume) * particleEmmisionRate + baseEmmisionRate;
        psMain.startSize = baseSize + volume * particleScale;
        psMain.startLifetime = baseLifeTime + volume * particleLifeTime;
    }

Testing what the fire looked like was quite a hassle, because I had to put on my headset, make noises into my mic, then take off my headset and then modify some values. So to make that a bit easier for myself I implemented a debug value that I can modify in the inspector that simulates an input value.

    [Header("Debug Tools")]
    [SerializeField]
    private bool debugMode;
    [SerializeField]
    [Range(0f, 1f)]
    private float debugVolumeValue;

Fixing the rotation

We already had a voice input rotation, but it was implemented quite weird which caused the object with the script to reset their rotation to their original rotation after a short while. Which looked quite snappy and weird. So I quickly made a script for it that worked. Of course I just reused my debugging lines for this.

    void Update()
    {
        ChangeRotation();
    }

    private void ChangeRotation()
    {
        float volume = GetVolume();

        // ignore soft background noise so the rotation can be 0
        if (volume <= 0.15f)
            volume = 0f;

        if (debugMode)
            volume = debugVolumeValue;

        transform.Rotate(Vector3.up * (volume * rotationSpeed * Time.deltaTime));
    }

My first step was to create a fire particle effect. I downloaded a pre-existing one () and slightly modified some values.

https://youtu.be/5Mw6NpSEb2o