How do I create or edit a collision poly at runtime?

0 favourites
  • 5 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I don't think this is possible at all, but I make overlooking another way to solve my problem.

    Ultimately, I want a behavior to be able to alter the collision shape of the object. In editor, I would achieve this by changing frames in a sprite animation and having a different collision shape, but that can't be done from a behavior.

    In the end, I would prefer being able to create any arbitrary collision poly at runtime. But baring that, I still would like to be able to set collision polys.

    Tagged:

  • I'm not sure that's possible, but if you're not using physics for the collisions and are merely using a hurt or hitbox, you can use image points, loop through it and draw boxes using those points. You can then use those to check for collisions.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can indirectly do it with a distort mesh since that distorts the collision poly too.

    Say you have 64 point polygon you want to use, you’d take a sprite with a square collision poly and apply a 32x2 distort and position the points to the poly. It won’t necessarily look pretty so you’d have it invisible and attach the visual on top of that.

    So apart from distorts changing or adding collision poly points nothing is setup for modifying collision polys outside the editor.

    Maybe with JavaScript but you’d have to bypass the scripting api to get into the unsupported and undocumented innards that has a has the possibility of changing per release and breaking anything you do with it.

  • So apart from distorts changing or adding collision poly points nothing is setup for modifying collision polys outside the editor.

    Maybe with JavaScript but you’d have to bypass the scripting api to get into the unsupported and undocumented innards that has a has the possibility of changing per release and breaking anything you do with it.

    I actually was hunting down what methods I might use. I see that you can use world info to get a poly's info, but so far I think the code for setting might be editor side.

    The mesh distort may be the way I go. I only need triangles and squares anyway.

  • Here's an example that uses mesh distort to make any polygon. Events 4-5 are the relevant ones. It takes the points variable as a comma separated list of xy coordinates as input. It sets the mesh size to 2 x count/2, then loops over the top row, and loops backwards over the bottom row to set the points.

    construct.net/en/forum/construct-3/how-do-i-8/manipulate-mesh-points-175978

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)