R0J0hound's Recent Forum Activity

  • It’s just built on top of the sdk template which specifies version 2 in the c3 addon.json. I’d assume the rest of the template is v2 compliant, but it’s not reasonable for us to find and update parts of the template that may use v1 stuff. Beyond that my goal is just to get it working.

    You can look at the runtime portions of official plugins in the browser console but the edit time portions are minified.

  • I finally fought through the build process to make a plugin. It's based on the drawing plugin template but a bit more complete so maybe it may be useful to you.

    dropbox.com/scl/fi/c8nu95x3r8mdjw15z7dcw/convexPolygon.c3addon

    It renders convex polygons, and lets you change the array json of the points at edittime and runtime. Also when it does it changes the size and origin so that the bounding box/quad is as small as possible around the points.

    I'm not encountering the bounding box issue you had.

    When you add it initially it's white so you'll want to change the color right after to add it. I wanted to set the color with code, like the spritefont plugin does, but that doesn't seem to be an option somehow. Also it looks like you have to manually add ACES to set the blend mode with events.

    I almost got used to modifying multiple files to add something. There really is a lot of tedium that you have to wade through to even get to the point of doing something interesting. The loop of modifying files, packaging them into a c3addon, loading it into c3 and restarting c3 to test it really takes a toll. Getting past the vague errors to even get the plugin to install was the biggest breakthrough I'd say.

    I found the SDK manual helpful in parts but overall hard to navigate, but that was mainly due to the sheer amount of different classes. When I got the the runtime portion the SDK docs stopped being helpful and had to resort to browsing code in the debug console. Turns out at runtime the renderer function names start with lowercase letters while edittime starts with Uppercase. Also it found it odd that the draw function had to be done differently at runtime than edittime.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Have you tried looking on discord? There were more active addon devs on there. There probably isn’t a simple graphical example, but you may be able to get some ideas by looking at existing plugins.

    I’ve looked into making a plugin a few times but decided the process isn’t something I wish to work through.

  • I mean, the last post was instructions of a way to do it. If I made a capx it would only follow those instructions. I’ll defer to other people’s solutions in the meantime. There’s a lot of other things vying for my time currently.

  • You do not have permission to view this post

  • There isn’t a best way. There are many different ways like I roughly listed in the previous post, each with pros and cons. But realistically you’d just pick one.

    Create a sprite and call it node. Give it two instance variables: path and index. You’d then place instances of node on the layout in the shape of the path you want. Next you’d set the instance variable values. You’d set index to 1 for the first node, 2 for the second, and so on. You’d then set path to the same value 1 for all of them. You can create more paths later by just having different values of path.

    Next you need something to follow the path. Create a sprite and call it mover. Give it two instance variables: path and target. Also give it the bullet behavior.

    In events you’d then do something like

    Start of layout 
    — mover: destroy
    
    On click
    Node: path=1
    Node: index=1
    Repeat 10 times
    — create mover at (node.x-loopindex*32, node.y)
    — mover: set path to 1
    — mover: set target to 1
    
    For each mover
    Node: path=mover.path
    Node: index= mover.target
    — mover: rotate 100*dt degrees toward (node.x,node.y)
    
    Mover: on collision with node
    Node: path=mover.path
    Node: index= mover.target
    — mover: add 1 to target

    You can change the rotation speed by changing 100*dt. You probably want to change the bullet speed too. Too fast with too slow of turning will prevent it from being able to reach the next node, but that’s easy to tweak. You can change the amount and spacing of the movers in the event that creates them. You probably want to delete the movers once they reach the end of the path somehow.

    As an exercise you could also stretch a sprite between consecutive movers to avoid visual gaps.

    Edit:

    Third party plugins are useful, but users seem to avoid them because they don’t like that the people that made them don’t usually stick around till the end of time to fix possible issues that come up from browser or construct change. You’re already using c2 that could possibly break from a browser change although that’s not very common. As to if third party plugins make it harder to port? That’s a question for those who do the porting.

  • I’m already unfamiliar with the game and the formula. But I’m assuming the formula is mostly correct.

    I’d want to verify this, but assuming it’s correct this should give to probability that exactly k of the unknown n dice are the same value.

    Prob(n,k) = fact(n)/(fact(k)*fact(n-k))*((1/3)^k)*((2/3)^(n-k))

    That’s with wilds. Without wilds 1/6 and 5/6 sounds reasonable.

    Normally for the ai to decide to say Liar or not it looks at the probability that there are at least k dice with the same value.

    So for example if there are four unknown dice.

    The probability of at least 2 being the same would be:

    Prob(4,2)+prob(4,3)+prob(4,4)

    And the probability of exactly two being the same would be

    Prob(4,2)

    The formula with the summarization I gave before would find at most or

    Prob(4,2)+prob(4,1)

    Which doesn’t seem right.

  • You shouldn’t need to be working with CssPx at all. The bounding box/quad is already in layout coordinates and the renderer takes layout coordinates as parameters. Also layout coordinates don’t change when the widow/scroll or the layout size changes.

    So for example in the draw() function of your plugin you could do something like this to draw a triangle centered on the object.

    const x=inst.x, y=inst.y;

    Renderer.convexPoly([x,y-50, x+50,y+50, x-50,y+50]);

    The bounding box would be based on the objects size and center so ideally you’d change the object size so that the bounding box would be tight fitting around the points of the polygon.

  • You probably should stop posting your question in both the c2 and c3 sections since you’re only after c2 solutions.

    C3 has the timeline editor which probably makes it easy to move things alone a path with minimal events. C3 also has the distort mesh where you can distort a sprite in a curved shape if you wanted.

    In c2 you have to come up with a way to define a path and move along it manually. Theres even some third party plugins to move along a curved path pretty easily.

    A cheap way to move along a path is to use the pathfinding behavior to move from point a to b through multiple waypoints to make the loop.

    You could also use the bullet behavior with a bunch of sprites places to make the curve. You’d have it target the first point by rotating the sprite toward it then when it collides start targeting the next and so on.

    Theres also some more rigorous mathy ways to go about it.

    To give it that curved line look you can just launch a bunch of sprites to move along the path and stretch sprites between consecutive sprites. There are also drawing plugins that possibly could be used for different looks. Or if you space the sprites close enough you may not need to stretch sprites.

    Basically looks like you’d define multiple paths. Then you’d pick one and spawn a bunch of objects to move along it at different offsets. Then you’d use stretched sprites or something to give it a continuous line look.

    Generating the paths on the fly could be possible too. But it doesn’t seem like something that video covers.

    Anyways, just some ideas.

  • That’s caused by the drawing order of images with transparency. Ideally polygons are drawn back to front, and construct generally tries to do that. The issue is just sorting the polygons won’t always work. I guess intersecting polygons is a common case that can’t be solved by sorting.

    One possible solution is to use a discard shader on problem sprites. What it does is not draw the transparent parts so stuff behind it is shown even if the order isn’t ideal. The only con is it would be a hard jump from transparent to not which may or may not look good in your project. Someone made one, but I don’t recall where. I think someone also made a dithered semi transparency effect too. Makes me wonder if you could render at double resolution and smooth resize it down to half resolution to get rid of dithering and hard edges.

    Another idea is to somehow control the sorting yourself to see if you can improve things. Fiddle with zorder and zelevation perhaps? In previous tests it wasn’t straightforward to override it. For example getting the walls to be drawn before the transparent stuff would help with the first artifact. For the second drawing the sword after the character would kind of help but I imagine the sword would get the clipping then.

    With the exception of intersecting polygons and cases where there’s a cyclic loop (ex: A in front of B, B in front of C, C in front of A) then doing a topological sort instead of a distance sort can help. But it’s probably not worth the effort here.

    Another idea is to split the objects into smaller ones. Or maybe dynamically split the intersecting polygons. An algorithm like BSP does that and likely would solve it. But again probably not worth the effort here and it would be rather heavy.

    Leveraging the gpu to solve it per pixel is another idea. Intuitively each pixel would be a list of colors and zdepths which would then be sorted. One algorithm called depth peeling supposedly does that semi efficiently. But that sort of thing is lower level than what’s really possible with construct’s renderer.

  • Well, what does construct provide to be able to do this? Maybe:

    System: pick 3dshape overlapping point (mouse.x, mouse.y)

    If the bottom of the 3dshape is on the z=0 plane then that will let you click on the bottom face. The other faces though? you're out of luck with Construct features. You'll have to do something from scratch...

    First you'll need the mouse ray. You can get that from the camera distance to the screen. One way to calculate that is from a non scrolling 2d layer: xyz: (mouse("2d").x-320, 240-mouse("2d").y, 240/tan(fov/2)). 320,240 is half the viewport size. Next you'll have to normalize that vector and rotate it by the inverse of the 3d camera orientation. That will give you a ray direction from the camera position.

    The second part is to do some kind of raycasting to see if and where the ray hits a 3d shape. Using an sdf with raymarching is a relatively simple solution for a single unrotated cube.

    dropbox.com/scl/fi/on24os5ezt8bqkugnea58/raycast_mouse_cube.c3p

    Overall for this kind of problem you figure out how to solve it from scratch and then adapt it to what features construct provides.

  • Roughly you’d calculate the angle difference between the two edges, and if the angle difference exceeds the angle limits you specified then you’d rotate the end edge till the angle is within range.

    We can calculate the angle of the edges with the angle() expression. To get the angle difference we could use anglediff() but we need the signed angle diff where its negative when CCW. That can be calculated with angle(0,0,cos(a-b),sin(a-b)). Then you’d check if the angle diff is greater or less that an angle limit. And if it is rotate the endpoint so it’s back in range. The formula to do that is:

    Pos: ((x-cx)*cos(a)-(y-cy)*sin(a)+cx, (x-cx)*sin(a)+(y-cy)*cos(a)+cy)

    As an example (barring any typos) this will move multiple instances of a sprite in a chain. The first instance will be moved to the mouse position, then all the following instances will be moved to be 32 pixels from each other. Then from the third instance on it limits the angle to the range (-10,10)

    Var p0=0
    Var p1=0
    Var p2=0
    Var da=0
    
    For each sprite
    — set p2 to p1
    — set p1 to p0
    — set p0 to sprite.iid
    — compare: loopindex=0
    — — sprite: set position to (mouse.x,mouse.y)
    — compare: loopindex >0
    — — sprite: move distance(self.x,self.y,sprite(p1).x,sprite(p1).y)-32 pixels at angle angle(self.x,self.y,sprite(p1).x,sprite(p1).y)
    — compare: loopindex>1
    — — set da to angle(sprite(p1).x,sprite(p1).y,sprite(p0).x,sprite(p0).y)-angle(sprite(p2).x,sprite(p2).y,sprite(p1).x,sprite(p1).y)
    — — set da to angle(0,0,cos(da),sin(da))
    — — set da to da>10?(10-da):(da<-10?(-da-10):0)
    — sprite: set position to (self.x-sprite(p1).x)*cos(da)-(self.y-sprite(p1).y)*sin(da)+sprite(p1).x, self.x-sprite(p1).x)*sin(da)+(self.y-sprite(p1).y)*cos(da)+sprite(p1).y)