R0J0hound's Recent Forum Activity

  • Here's one idea:

    Attach the bowl to an immovable physics object with a revolute joint.

    Then change the angular velocity to turn toward the angle you want.

    Details with some more explanations:

    dropbox.com/s/fp0hrl9f73f10yh/physics_rotate_bowl.capx

    In general think of setting angle or position of physics objects as the same thing as teleporting. In your example you set the angle directly so if you rotated the bowl object fast enough the balls could suddenly be on the other side of the walls of the bowl. The physics engine won't think the balls went though the walls.

    However when setting velocities the physics engine can do it's magic to avoid jumping through walls. Especially if the "bullet" setting is enabled which does continuous collision detection.

  • For physics to work best you'll want the motion of objects to only be handled by the physics behavior. Any other behavior will interfere. Also at no time use set position or angle. You can set angular/linear velocities, apply forces or impulses to move things.

    For something like a rotating box you'll need to do that with joints to put it together. Then with the "bullet" setting the balls will bounce off walls no matter how thin.

    dropbox.com/s/yh0tj716maey831/continuous_collisions.capx

    Of course you still can overpower the joints at times, but usually it's stable.

  • Only use the physics behavior, and there’s a continuous collision detection check mark I think.

    Physics doesn’t work with other behaviors.

  • You can do something like this using sub events and else. It should be straightforward.

    start of layout
    -- compare: choose(0,1)=0
    -- -- create at 300,400
    -- else
    -- -- create at 100,100

    You could do it slightly different with mostly equations but the result would be the same. I typically go for whatever is easier for me to read.

    var section=0
    
    start of layout
    -- set section to choose(0,1)
    -- create at 0,0
    -- set x to section?300:100
    -- set y to section?400:100
  • You could do something like:

    choose(random(95,210), random(350,450))

  • You’re correct, there isn’t an expression for the gravity. It’s by default 10, but I usually use a variable to store the value and set the gravity with that.

    Sometimes the manual lists the exposed js values/functions for behaviors, but if not I try to use console.log with an object and then open up the browser debugger and browse the members, sub-members and so forth.

    Basically what you’re after is to

    1. Find an instance of an object with physics

    2. Access the physics behavior instance.

    3. That should have a reference to the box2d world. If the behavior instance doesn’t have it then you may find it in the behavior instance’s type which you should be able to find a reference.

    4. Once you get the the box2d world you should be able to find the gravity vector.

    Anyways that’s the rough process I use to try to find stuff in js.

    I’m not on my computer but if you used the browser execute js action you may be able to access the gravity with something like:

    this.runtime.getInstanceByUid(3).behaviors[0].type.world.gravity

    The names of everything are probably incorrect so I’d have to check along the way with console.log to see what the correct names are. That and it may be a slightly different path.

  • Here is the reverse conversion:

    Percent=100*10^(decibel/33)

    So with -7db you’d get the x position on the slider with:

    X=Bar.bboxLeft+ Bar.width*10^(-7/33)

  • You can adjust the formula to give -10 for half. My researching have shown -6db for half in other apps but maybe construct is using a slightly different curve. Godot docs for example uses -6db for half and construct docs use -10db for half.

    Anyways no matter. We can adjust the formula to match construct’s db scale.

    -10/log10(0.5) =~ 33

    So you can use

    Decibel = 33*log10(percent/100)

  • According to the construct docs -10 is half but other sources online show -6 as half for standard audio decibels. Maybe construct uses a different scale? Or maybe it was a typo?

    At any rate if you want it to match the construct docs just change to formula to:

    33*log10(percent/100)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I read a bit more on it.

    With decibels, 0 is full volume and about -80 is sufficiently quiet to be considered silent. Subtracting/adding 6db will half/double the volume.

    So far so good. But using 20*log10(percentage) you get the same result:

    Full volume (1) will give 0.

    Half volume (0.5) will give -6.

    Quarter volume (0.25) will give -12.

    Either seems viable to setting volume and you can convert between the two and get expected results. The underling webaudio api uses percentages for volume.

    Anyways, it’s merely a preference. People who have done a lot of audio processing seem to prefer decibels and a lay person like myself likes percentages.

  • Still whenever making a volume slider it’s still needed to convert a percentage to decibels. 0db is full volume and -infinity is silent.

    Db = 20*log10(percent/100)

    Does that. At least it’s correct at those two points.

    Guess you could do the volume slider like this if one wants to stay in decibels. The -1000 is arbitrary though. Technically should be -infinity to be silent but at some point it’s probably quiet enough but that would have to be found by trial and error.

    Db = lerp(-1000, 0, percent/100)

    Anyways my opinion still stands about decibels and percentages. Percentages are more intuitive to me. Decibels have their use for sure but I haven’t found them useful for my purposes.

  • Here’s a post with the formula to convert a percentage 0-100 to decibels. I never understood why this was the default since percentages are way more intuitive and actually is what webaudio uses behind the scenes.

    construct.net/en/forum/construct-3/how-do-i-8/user-change-volume-percentage-162705

    If I understand how you’re selecting the volume with a click you should be able to get a percentage with:

    100*(mouse.x-bar.bboxLeft)/bar.width

    Then just convert that to decibels with the formula in the link above.