R0J0hound's Recent Forum Activity

  • I can’t wrap my head around a solution to that. As is the impulse corrects the position but as the length is changing the velocities would have to be updated somehow.

    I tried gradually changing the length with a force but haven’t had much success.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don’t think the audio plug-in has been updated with 3d in mind. You could make a feature request to give a z height to the positioned audio since webaudio already has that available, construct just doesn’t use it.

    A second option would be to calculate the volume from the 3d distance to the listener and the falloff equation. It’s mostly just busywork to workout the formula.

    A third option would be to use JavaScript instead to do the audio plugin. There are various libraries that could work or if you could use webaudio directly.

  • There isn’t one way you have to do it. You can set it up any way you like. With any setup you’ll have to do some juggling with events.

    If it’s any consolation I find any changes to this to be complicated too. I attempted to simplify things into manageable chunks but I still find rough to debug or modify.

  • All the code refers to same sprite type. The new choices are a different type.

    I made all the numbers be the same type and used a group variable to differentiate between then to reduce the amount of events.

    There are many ways to setup the events. Currently it does most of the stuff with variables and only deals with sprites when displaying. Nothing is automatic. To display it picks a certain group of sprites and sets it from a certain variable.

  • Here’s the rope joint done with impulses. 100 is the max distance. The /100 at the end was to scale things down.

    dropbox.com/s/bpxf1z9zws5e1t8/Ropejoint.c3p

  • The physics behavior doesn’t provide that joint.

    A few ideas come to mind though.

    1. Is to do event based physics using verlet. I’ve made rope examples that do that. It’s as simple as if the distance is greater than a certain amount the objects are moved toward each other to correct that, then the velocities are updated. The cons are it’s independent of the physics behavior and working with ridged bodies will require more code.

    2. Joints in the physics engine are done with impulses behind the scene so in theory you could make the joint you want with that. I fiddled with the idea a bit and something like an impulse of (distance-100)/100 toward the other object seems to work but is bouncy. For better results we could copy what impulses box2d calculates for such a joint.

    Edit:

    If d is the distance between the objects and ang is the angle between them, then the impulse should be the following when dist<100. At least from what I’ve read.

    ImpulseAtoB= -(d-100+(A.vx-B.vx)*cos(ang)+(A.xy-B.vy)*sin(ang))/(1/A.mass+1/B.mass)

    I’ll test this later. The units may be off.

  • VectorX = speed*cos(sprite.angle)

    VectorY = speed*sin(sprite.angle)

  • I apologize, I’m not great at reading events at the moment. I thought I had given a solution to your last question in one of the first files I posted. I think I’m causing more confusion with every new capx I post since I do things slightly different over time.

    In the last capx it just makes three shuffled value. If they are all unique (don’t equal each other) then one is picked randomly to be the right answer.

    You could just make two shuffled values and make them unique by comparing with each other and a correct answer.

    I’d recommend doing some tests to swap two values or two positions of objects. Once you can do that you have all the tools you need to shuffle anything.

    In general you could swap a and b with:

    Temp=a

    A=b

    B=temp

  • Yeah, even though I provided the ideas in that screenshot I'm confused by what it does.

    Here's a capx of that pseudo code I posted. To simplify things It uses variables, and functions to organized the steps. The sprites are all the same type and are set as the last step. Again, that was to simplify things and need less events.

    dropbox.com/s/n3ewz0wklyzh26w/shuffle_and_reorder2.capx

  • The issue you’re seeing is you cannot pick two separate instances of an object like that.

    One common solution is to use a family with just that type. But you’d need to only add instance variables to the family.

    For each sprite
    Other: instance = sprite.instance+1
    — create spriteB at (other.x+sprite.x)/2, (other.y+sprite.y)/2

    Another idea is to pick one, save the data you need to variables, use “pick all”, then pick another.

    Var otherx=0
    Var othery=0
    Var otherInst=0
    
    For each sprite
    — set otherx to sprite.x
    — set othery to sprite.y
    — set otherInst to sprite.instance
    — pick all sprite
    — sprite instance = otherInst+1
    — — create spriteB at (otherx+sprite.x)/2, (othery+sprite.y)/2
  • Create by name has limited use to me because of that. But one solution is to make an “on created” for each type to set a variable. For example something like this:

    Var uid = -1
    
    On sprite created
    — set uid to sprite.uid
    
    On sprite2 created
    — set uid to sprite2.uid
    
    Start of layout 
    — set uid to -1
    — createByName(“sprite”)
    — if uid=-1
    — — set text to “no object created”
    — else
    — — set text to “new object created ”&uid

    On a side note wait 0 is a popular hack in relation to being able to create newly created objects. But I avoid if at all possible other than in quick tests.

  • It’s just an overview of how to do it.

    Previous capx show ways to represent the numbers as sprites or variables, ways to shuffle the values, and to reorder one list with another. They are building blocks to do the rest.

    I tend to break things down into general chunks like that otherwise I get lost in all the details.

    It will take a few days to get time to implement it.