Licence od 75 € Přihlásit se
DE EN FR ES IT CZ

[Solved] Volume control via script

Toto téma je několik let staré. Některé údaje se mohou týkat starší verze Visionaire Studia. Aktuální návody

  1. · 10 years ago
    Hi smile

    I'm trying to control Music, Voice and Speech Volume in my Game.

    The process

    I have created a Menu that looks like this:



    First of all, I have an animation with 10 frames.
    Animation name is "Music_Volume_ANIM", inside "Music_Volume" scene object.



    Each frame represents a volume status, from o (empty) to 11 (full).
    So frame 1 represents volume 10, frame 2 is for volume 20 and so on.


    The animation is set it to infinite loop and it is the default animation for the scene object.
    The pause between frames is 100ms. 



    Then, as AFRLme suggested, I created a called by other action part.

    local vol = getVolume(eMusicVolume)
    
    if vol >= 0 and vol < 10 then 
     ActiveAnimations["Music_Volume_ANIM"].AnimationFirstFrame = 1 
     ActiveAnimations["Music_Volume_ANIM"].AnimationLastFrame = 1
    elseif vol >= 10 and vol < 20 then 
    ActiveAnimations["Music_Volume_ANIM"].AnimationFirstFrame = 2
    ActiveAnimations["Music_Volume_ANIM"].AnimationLastFrame = 2
    
    ...
    end




    The script contains all volumes from 0 to 100.
    This script is an execute a script action part inside of the first frame of the "Music_Volume_ANIM" animation.



    This is where the script is called


    The animation is the default animation, so it starts automatically:

    --------------

    The issue

    When I test the scene, Music_Volume_ANIM loops, apparently ignoring the AnimationFirstFrame and AnimationLastFrame.

    The log file is empty.

    Any help is appreciated, thanks! smile
  2. Pracujete na hře?

    Bezplatná verze umožňuje až 25 scén na projekt. Pro více scén a pro prodej hry potřebujete licenci.

    Zobrazit licence Vyzkoušet zdarma
  3. · 10 years ago
    couldnt you just use one frame and instead move the animation position to the correct location? 
  4. · 10 years ago
    Thanks Sebastian, that's a good idea too smile

    For those find this useful,  I have found the issue btw:

    "The script contains all volumes from 0 to 100."

    the last elseif in the script was written like this:

    if vol >= 90 and vol < 100 then 
     ActiveAnimations["Music_Volume_ANIM"].AnimationFirstFrame = 11 
     ActiveAnimations["Music_Volume_ANIM"].AnimationLastFrame = 11
    end

    But... yes it sound obvious now... volume is 100 by default.
    So if I type < 100, 100 will not be included.

    The correct version is

    if vol >= 90 and vol < 101 then 
     ActiveAnimations["Music_Volume_ANIM"].AnimationFirstFrame = 11 
     ActiveAnimations["Music_Volume_ANIM"].AnimationLastFrame = 11
    end

    (or <= 100)

Toto téma je uzavřené, protože tu přes rok nikdo neodpověděl. Svůj dotaz můžete položit v novém tématu.

Nové téma

Opravdu smazat tento příspěvek?