R0J0hound's Recent Forum Activity

  • I was more focused on getting the math right than the expressions write when I wrote it in the previous post. So velocityX should have been self.8direction.vectorX but the idea is the same.

    We aren't setting the angle with that; we are only measuring it.

    A quick fix for the shaking could be to multiply w1 and w2 by 0.5 or something when correcting the velocity.

    A more correct fix would be to calculate the relative velocity between the two objects in the angle between them and using the weights (w1,w2) in the same way.

    Here's an iteration of that:

    dropbox.com/scl/fi/jrr6hko1kq0xwy77mqxr4/tetherObjects_noDragging2.capx

    The angle can still shake though. That mostly has to do with how the angle is set from the angle of motion. Instead, you probably want the angle to be set to the angle the player is trying to go.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I ended up implementing it and simplifying the math a bit.

    No dragging:

    dropbox.com/scl/fi/3dpr622etyygcxk4cuom7/tetherObjects_noDragging.capx

    Older example with dragging:

    dropbox.com/scl/fi/sflsjyje1eqwgtxhk9qjb/tetherObjects.capx

    As to understanding the formulas, maybe this will help a bit. The w1,w2 formulas are basically the calculated speed along an angle.

    speedAlongAngle = velocityX*cos(angle)+velocityY*sin(angle)

    It's positive if moving along the angle, and negative if moving the other way. We only want the speed moving away so we clamp it with -min or max so we only have positive speeds.

    Then we calculate the distance for the two objects to move back toward each other with (d-radius). That needs to be split between the two objects, and I'm using w1/(w1+w2) and w2/(w1+w2). They add together and give one so it's a complete split. It's mostly so if only one object is moving only it will be moved and vice versa.

    The last part is to cancel out any velocity trying to move the objects further apart. We already have the speeds moving apart w1,w2 and we just need to convert the angle, speed to xy components with: x=speed*cos(a), y=speed*sin(a).

    The negatives are just to invert the direction. Anyways, maybe some of that explination helps. It's a combination of a lot of simple things.

  • The no dragging part seems like an interesting twist. You can limit the position of one player or the other with:

    Dist = distance(p1.x,p1.y,p2.x,p2.y)
    Ang = angle(p1.x,p1.y,p2.x,p2.y)
    P1: move max(0, dist-radius) at angle ang
    Or
    P2: move -max(0, dist-radius) at angle ang

    Which works well if only p1 is moving or p2 is moving. If both are moving then both should only move apart by a percentage. I’d think using the speed at which each is moving away from each other should give a good percentage.

    Dist = distance(p1.x,p1.y,p2.x,p2.y)
    Ang = angle(p1.x,p1.y,p2.x,p2.y)
    W1 = max(0,p1.velocityx*cos(ang+180)+p1.velocityY*sin(ang+180))
    W2 = max(0,p2.velocityx*cos(ang)+p2.velocityY*sin(ang))
    P1: move max(0, dist-radius)*w1/(w1+w2) at angle ang
    P2: move -max(0, dist-radius)*w2/(w1+w2) at angle ang

    Id have to test it though. Also it doesn’t cancel the velocity going away from the radius. I’m pretty sure that could be done with:

    p1 set velocityx to velocityx-w1*cos(ang+180)
    p1 set velocityy to velocityy-w1*sin(ang+180)
    p2 set velocityx to velocityx-w2*cos(ang)
    p2 set velocityy to velocityy-w2*sin(ang)

    But again I’ve yet to test it.

  • Is there any game with such a thing?

    If you did it straight, then just do it curved. Place multiple sections down, each angled a bit more, then create the joints.

    Look again at the actions of the physics behavior. You can disable physics collisions between objects.

    Or you could just have the end have physics with a spring joint moving it back into place and have the the rest just be sprites without physics positioned in a curve with qarp() or something.

    I don’t even know if the physics behavior has a spring joint. Anyways you could do a spring by constantly applying a force toward a rest position.

    ForceX = -k*(self.x-restx)/dt-b*self.velocityX

    And the same for y force, just with y stuff. K and b are the spring stiffness and damping. Usually in the range of 0 to 1 but you’ll just have to fiddle with it. Probably will want to put that under a condition of dt>0 since dt can be 0 which would give infinite force.

  • I don’t have an example. But since you only use C2 a non third party solution could be to load the image you want to sheer into the sprite’s animations as a sprite sheet. So say the image is 320x64 you’d import that image with spriteSheet import with 1,64. That would give you a bunch of 1 pixel tall strips of the image. Be sure to set the animation speed to 0. And probably set the origin to the top left.

    Next is to place it. It’s a pain to place 64 instances and set the frame of each one so you can do that with some events:

    Start of layout
    Repeat 64 times
    — create sprite at (0, 480-64+loopindex)
    — sprite: set animation frame to loopindex

    Then to sheer right you can do:

    Sprite: set x to self.x+lerp(10,100, self.iid/64)*dt

    Where 10 is the speed of the top row and 100 is the speed of the bottom. Tune the values to your liking. Moving left would just be subtracting.

    You can avoid the image slicing step by using a tiledbg. The con with that is there will be more overdraw and the sides of the sheer will look off

    Start of layout
    Repeat 64 times
    — create tiledbg at (0, 480-64)
    — tiledbg: set height to 64-loopindex

    And

    Tiledbg: set x to self.x+lerp(100,10, self.iid/64)*dt

    Notice the 10 and 100 are reversed.

    Beyond that you could use a third party plugin to do a sheer. Paster is one option with its draw textured quad action. You’d basically just select a sprite to get the texture, and set the four corner positions.

  • You could also apply a sheer with mesh distort if you want to do it in the same way they did it in sf2. Basically make a 2x2 mesh and move the top two points left or right by the same amount.

  • Guess you could just start with a polygon with say 30 points and drag the points around to sculp it. Could use some math to do falloff brush so it would move more points at once.

    Then just reuse the small bit that converts a list of points to a distort mesh. If the polygon ever gets concave then it may visually not look right but there are probably ways to solve that. However if the user keeps the shape convex it should be fine.

    Guess there are other interesting ways to modify the shape. Maybe a convex hull of multiple basic shapes you can drag around. Or maybe some csg combinations of basic shapes. We can get away with slightly concave stuff on one axis with one distort mesh, but multiple meshes would be needed for severe concavity.

    Just some ideas. I like to push what’s possible. Construct provides some basic stuff, but with math, geometry and algorithms it’s a bit more open ended. To a point at least. Construct features have limits that can require some creativity to work around.

    Nothing wrong with scoping down to do something that’s more doable. Worst case you could just have a bunch of premade body shapes the user could pick from. Or like dop suggested assemble stuff from parts. You wouldn’t have to deal with polygons then.

  • Here's this week's test. Event based Marching Squares to extract polygons from an image, then uses mesh distort to change the polygon. I would have guessed that we'd need js to do this fast enough, but events seem fine.

    dropbox.com/scl/fi/1s0xet28gg4h9aiwaz6li/marchingSquares.c3p

    Here's some older stuff I didn't reference. They use a handmade js implementation of marching squares.

    dropbox.com/scl/fi/1wuqpu4xe05bto5im4kh1/marchingSquares.c3p

    This one seems broken. Sizes are off

    dropbox.com/scl/fi/cuvne5uvea1yhwv1aodlu/marchingSquares2.c3p

    Anyways, just some stuff to mess around with.

  • It’s just a lot of work and maintenance with not much to gain.

    As is it’s probably simple enough to use some JavaScript to load the rive library and have its own canvas on top of constructs canvas. Is that integrated? I’d say no, just construct and rive stacked on top of each other.

    To make a plug-in there is a fair amount of work to create the properties/consitions/actions/and expressions. Plus if rive uses some other data types besides numbers or strings the plugin will have to implement a system to deal with that. Another big thing is having rive objects render with constructs renderer. As is construct’s renderer isn’t super feature rich so it likely cant render everything rive needs. Solutions include rendering to its own image and copying that over to a texture, but that memory transfer will be a performance hit. The other option is to try to use webgl and/or webgpu directly and still play nice with constructs renderer. The second way will require long term maintenance as it would be fairly sensitive to any updates constructs renderer has.

    That’s just to interact with rive and get it to render in constructs canvas. Tighter integration will require more work resolving differences. And should you want it to interact with other construct features more will be more work on top of that.

    Overall there will be a fair amount of connecting code to integrate them. So it’s a long term project unfortunately.

    You can look at plugins for Spine or Spriter to get a general idea of what kind of integration you’d get with something simpler.

  • You can change the sprites origin point in the image editor. Just move it to the center

  • Unfortunately this is in the realm of impossible to debug from screenshots.

    If all the bullets are getting destroyed then you’ll want to look at all the places you destroy them. Or maybe you have a behavior that destroys them like fade.

    Logic wise I’d say the hot spots to look at are your events around the waits and the else events. Maybe the logic is doing something unexpected.

    If I end up with events that don’t work as expected I try to isolate it, and maybe incrementally re-build it a bit at a time while doing tests as you go.

    Events have a fair amount of hard to follow edge cases so I’m often either just using stuff I fully understand or doing extra tests while I implement stuff.

    Anyways, good luck

  • There is animation software that does that sort of thing like spine or spriter.

    But the idea is simple enough. To animate you just move objects to different positions. You can get away with less key frames by using an ease to blend between frames. And that’s about it. The rest is just creativity.

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound