R0J0hound's Recent Forum Activity

  • Sure, the physics is a position based dynamics simulation, so you just need to move the points.

    left is pressed

    — p: set x to self.x-100/60

    Just put that event towards the top of the event sheet. That would move it left at 100pixels per second at 60fps.

    But we can probably do better. Instead of moving all the points we could move the top ones more than the bottom ones, which would let it roll.

    Var ymin=0

    Var ymax=0

    For each p

    — set ymin to loopindex?min(ymin,p.y):p.y

    — set ymax to loopindex?max(ymax,p.y):p.y

    Left is pressed

    — p: set x to self.x-(self.y-ymax)/(ymin-ymax)*200/60

    That should move the top points more than the bottom ones. Might need to change the 200 if it doesn’t move it enough to roll.

  • I think it’s in notification settings under construct 3 updates. I have both turned off but hopefully the second unnamed one is that

  • I guess you could give the bowl more mass or the balls less.

    If the balls are still leaking through then you are running into the limits of what that particular physics engine can do. Probably need to reduce speeds and make things move more gradually like changing the 10 to a smaller value. That or make things bigger. Those things and my precious suggestions in theory should help prevent objects from passing through each other.

    I think overall the physics engine was made to be general purpose and work pretty well. It is possible to break the simulation pretty easy though. When that happens you just have to dial things back I suppose.

    Reduce speeds, enlarge objects, make the masses more similar. Might be able to make it run better by increasing the iterations of the simulation. There’s an action for that. Not sure.

    The alternative is to scrap using the physics behavior and just devise a way to keep the balls from moving through walls with raycasts or something. The con of that is the rest of the physics would need to be done too. I don’t really think a hybrid approach would be any easier than from scratch.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah. Yeah I did link the wrong file. Fixed now.

    It uses the 8-direction movement and does the z axis movement with events. It toggles the solid behavior as needed and checks what blocks are above and below the player to handle z-axis collisions.

    Camera controls are completely independent of this. So I didn’t move it at all.

  • Depending on how deep you want to go you can get 3d collisions with a bunch of math.

    Using oosyrag's idea you can see if two boxes also overlap on the z axis with:

    box1 is overlapping box2
    box1.z>box2.z-box1.depth
    box1.z<box2.z+box2.depth
    -- do something

    Or if you want to find the next box below the first box:

    box1 is overlapping box2
    box2.z<box1.z+box2.depth
    pick box2 with highest z
    -- do something

    Pseudo logic of utilizing that could be:

    move on z axis
    if overlapping in 3d: move up
    move on xy
    if overlapping in 3d: move backwards

    More finesse is needed to make it smooth. To have wall sliding or some more robust collision response you'd need SDFs(signed distance fields) or SAT(separating axis theorem) or probably some simplification of those.

    Heightmaps are also a technique to do terrain. You just need either a function that gives a height for an xy position. That can be done either with some equation or sampling an array of values with interpolation or sampling from a noise function.

    After that it can get a lot more complex. In general a good practice is trying to to do collision detection and response in 2d first with just events or js. Most of the ideas do carry over. Overall it may be more involved than most want to deal with.

    Here's a possible example of being able to jump on and go under 3d blocks. There was more nuance than I anticipated, but maybe it's useful.

    dropbox.com/s/4j93hionaa1c6qn/simple3dplatformer.c3p

  • 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)