R0J0hound's Recent Forum Activity

  • Mousedown triggers when a button is first clicked. Even if you clicked both buttons at the same time mousedown would be called for each button individually. You can’t directly query the state of a button with the browser so a solution is to just update some variables from mousedown and mouseup events, and then you can look at those variables to access the current button state.

  • You can look at the obj file in a text editor to see if it looks correct. The lines starting with v are the vertices and there is only 8 of them if it’s a cube.

    Other than that I can’t really help. The obj file format is simple and having it load with the wrong offset and size isn’t really the kind of mistake that would happen in the loader.

    So I guess just try to fix the cube in that 3d program, and maybe check the meshes you’re using for the ground or other objects you’re trying to align with.

  • Three changes and it will work.

    1. Make the gravity local variable static. Since it’s in a group it’s just a local and gets reset to 0 every tick as is.

    2. Make the gravity variable x50 times what you use for the physics behavior gravity. Why? With box2d the standard use is to scale the physics units from the pixel units. That shouldn’t affect us but when they made the behavior they didn’t make sure the units were all uniformly converted. So x50 comes up a lot.

    3. Use (vx,-vy) when you set the velocity. A negative was forgotten when solving the formula.

    And as a bonus:

    4. Use (vx,-vy-gravity/60/2) when you set the velocity. Without that the path will be slightly lower than the target. Why? There is something off when things update in the behavior. It applies gravity once. However I think this mainly happens when objects with physics are just created. I honestly forget, but in the chipmunk behavior I made a point to avoid that quirk.

    Cheers

  • That example should have what you need. I mean you can calculate it yourself too if you want. The equations for projectile motion is this. X0,y0 is the start position, x1,y1 is the end position, vx,vy is the launch velocity, a is the gravity, and t is the flight time. You can then use algebra to solve for the unknowns.

    X1=X0+vx*t

    Y1=Y0+vy*t+0.5*a*t*t

    But anyways. With the physics behavior it should still work. Just set the velocity on launch and you won’t have to worry about mass. With damping at 0 it should be flawless, but damping in general would throw it off. I don’t know if anyone worked out how damping is done to work with that.

    Maybe you’re making a typo or something when adapting that example to your events.

  • megatronix

    Always nice to hear the plug-in being used. Time and motivation are the main obstacles of most of my projects. But anyways.

    I’ll look up that program. There’s always interesting ways different programs do things.

    Which load action? There’s one to load an image file, one to grab a sprite texture and one to load an obj file. Obj files are a simple text based 3d model format. You could probably generate a file from the vertices. Just save the xyzuv of the vertices to an array as you add them. Then you’d add two lines for each vertex in the file: “v x y z”&newline&”vt u v”&newline. Then you’ll need to add the faces. Every three vertices define a face so this would generate the face data:

    Var i=0
    Repeat int(vertexCount/3) times
    — set i=loopindex*3+1
    — append “f “&(i)&”/“&(i)&” “
    — append (i+1)&”/“&(i+1)&” “
    — append (i+2)&”/“&(i+2)&newline

    Collisions are a can of worms. Storing all the xyz’s of the vertices is the first step. Then if you transformed the object using that mesh at all you’ll need to transform those points too. Basically xyzVector *scaleVector *orientationMatrix+positionVector. After that, each group of three vertices define a triangle. And after that… I guess it depends on what kind of collision detection you want. There are a lot of algorithms different algorithms and I can’t do them justice off the top of my head. Tri vs Tri could be done with SAT, MPR, GJK or maybe calculating the line where the two planes making up the triangles intersect, clipping the line by the edges of both triangles and if there’s anything left it’s a collision. Those first three algorithms work with all the points of convex solids and will give some collision info such as normal vector and where.

    I don’t think I’m scratching the surface though. In general to make things faster you’d use a simpler collision mesh instead of the visual one, or approximate it with simpler primitives like spheres, bounding boxes, oriented boxes, capsules, height maps etc. However in the construct realm I think the simplest solution is just do all the collisions in 2d and have the 3d just be a visual. You can look at any 3d collisions people are doing in c3 for some ideas too.

    The process for implementing any of that is to find an algorithm online somewhere and adapting that to events. I can only give an overview here atm.

  • Mesh point positions aren’t in layout coordinates, they are relative to the object’s quad. So 0,0 is the top left corner and 1,1 is the bottom right. You’ll have to convert it over. So say you want to use x,y as a position you’d need to do:

    X=(x-self.x)/self.width

    Y=(y-self.y)/self.height

    Texture coordinates are similar.

  • It comes down to there is no perfect solution. You have to deal with some complexity somewhere.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I’d just make an invisible spikySprite that would be created over anything you want to be spiky. Placing them over all the relevant objects is pretty straightforward with events. And you could use pin or something to attach it to moving objects.

  • igortyhon

    No worries, I just made a new topic to share the solution. This is at least the second time that user deleted a topic I posted a solution to. No harm done though, I should recognize his username next time and save the posts so I can repost the topic. I was curious to check out your example as well but the link was broken for me when I tried it.

    New topic

    construct.net/en/forum/construct-3/how-do-i-8/re-generate-level-map-179636

    MPPlantOfficial

    Apologies for derailing your topic. Tangent over.

    -cheers

  • There was an interesting question posted asking for a solution for generating a branching path but seems the topic was deleted by the user jentry after he got a few solutions.

    Deleted topic:

    construct.net/en/forum/construct-3/how-do-i-8/generate-level-map-179620

    Oh well, I think he did that to me before after I posted a solution to one of his other topics. Actually, looking at his posting history he deletes everything. Good to know.

    Anyways!

    I thought the solution was interesting enough to post again. It generates branching paths like this:

    The algorithm I came up with starts with multiple parallel lines with nodes in columns, and it repeatedly collapses random adjacent nodes in the columns. This image roughly illustrates the algorithm:

    Download link. In code blocks because this forum breaks new dropbox links otherwise.

    https://www.dropbox.com/scl/fi/ukgwp8kful81ztfg7s3qc/branch_path_gen.capx?rlkey=nsyu7ofa95ie9sng6b7a0xeeb&dl=1

    There is probably cleaner ways to implement it.

    igortyhon also posted a solution but I didn't get a chance to download it.

    -cheers

  • No violation that I know of. The original poster probably deleted the topic and it took all the replies with it. I’ve seen it happen before a few times. I guess this forum allows that but it always irks me a bit. We go out of our way to post a working solution to a problem and they get selfish and delete the topic after they get it. The solution was meant to help them, sure, but it’s also for the benefit of anyone else browsing the forum.

  • Mesh points are positioned relative to the object’s quad. 0,0 for one corner and 1,1 for the other opposite one. It’s a bit different but setting the pos to 0,0 and the size to 1,1 is one way to let you use layout coordinates and mesh point positions. Another way is to take and xy position and convert it with:

    (X-self.x)/self.width

    (Y-self.y)/self.height

R0J0hound's avatar

R0J0hound

Member since 15 Jun, 2009

Twitter
R0J0hound has 155 followers

Connect with R0J0hound