R0J0hound's Recent Forum Activity

  • kmsravindra

    You could draw an identical arc over it, only instead of black use white. A better way would be to keep a list of all the things drawn and then remove the arc from the list, clear the canvas and redraw everything from the list.

  • sqiddster

    It may be slower than iterative methods since calculating intersection points isn't too cheap. With many objects it would be a problem, so any techniques to cull objects you don't need to cast to should help. The main use I have for it is to find an exact point of collision, and also the angle of the edge hit (although that's not present in the capx).

  • Maybe use int() instead of round() in round(random(0,arrayFrame.width)).

    Using round() can cause frameArray to equal arrayFrame.width and trying to delete that index will have no effect.

  • If you want to go the racasting route, here's an example with a re-usable raycaster event group that I've been using. It only needs the Function object to copy over.

    https://www.dropbox.com/s/qfjyoluo4eo83 ... .capx?dl=0

    To use set the start and end points of the ray with "raycast.set ray".

    Then call "raycast.cast to" with the endpoints of every line segment you want to cast to.

    Then use the functions "raycast.get x", "raycast.get y" to get the collision point or the end of the ray line segment if no collision occurred.

  • you can use "time" which gives you seconds. On the plus side is it's a decimal number so you can get a time of 0.456 or something. To get milliseconds you can multiply it by 1000.

  • [quote:1nb3nvgu]Well that's too bad because it seems like the OnCollision Trigger "knows" there was a collision and must know where it is on the screen. Too bad it doesn't return or populate a system variable like: Sprite.OnActiveCollisionX and Sprite.OnActiveCollisionY

    It doesn't know where the collision occurred, it would have to be calculated in js in the same way as listed here.

    sqiddster

    A plugin could access the collision polygon. The physics, polygon and chipmunk already do internally. In just events you could place imagepoints in the places of the collision polygon points for a brute force way. Then you can do line intersections with:

    http://paulbourke.net/geometry/pointlineplane/

    I can find a capx where i've implemented it if needed. A plugin could be made to hide the complexity, but I don't enjoy the process of updating and fixing plugins currently.

  • Prominent

    Yeah, it looks like it's from the previous position. You can try adding these two lines to line#6528 :

    binstA.updateC2(binstA.body);

    binstB.updateC2(binstB.body);

    That should update the c2 object from it's physics body. I haven't tested it, so I don't know if it has any other side effects, because usually it's only done at the end of the tick. Looking at the function it may but I don't have the time to really analyze and debug it.

  • The fact the laser is growing fast or that the objects are moving is not really a problem. The same idea can be used. If the laser at any point overlaps the object, then in with a loop make the laser a little shorter until it's not overlapping the object. At that point the end of the laser is the collision point.

    Another way would be to do a raycast with math, which basically amounts to calculating the intersection points of the laser line and the edges of the object and keeping the closest intersection.

    You could also utilize the chipmunk behavior as it has some stuff built-in to get the collision point. Vanilla C2 collision detection only finds if two objects intersect, at no point is a collision point calculated so you'll have to use one of the above approaches.

  • Prominent

    I forget exactly where. Search for "poly" in the runtime.js for how I accessed it. It was basically mirroring what the built in physics behavior does. They both use some helper functions that are defined in commonjs.js. (I think that's the file, it's in the exporters/html5 folder).

    The functions allow you to get a list of the points that make up the collision polygon, but transformed to match layout coordinants. The sprite behavior may be another place to find the list of points.

  • Prominent

    The best way I can think of would be to create an object at each corner and use the "pick nearest" condition. You'll probably need to define the corners with imagepoints to do that.

  • In the simple case set a variable to the current time "on touch". Then you can get the duration of the touch from "is touching" with time-start_time.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • One approach is to move the laser backwards until it's not overlapping the other object, then the end of the laser would be the collision point.