Create a spark at precise collision point?

0 favourites
  • 15 posts
From the Asset Store
Connect the dots in the correct order and draw happy animals!
  • I've been looking through thread after thread and there doesn't seem to be an easy way of retrieving the exact point where two objects (say, a sprite and a tiled background) collide. I want to create a little spark when my car touched a wall, but I want the spark to occur at the exact point on the car body where it hits the wall on the correct side of the car, at the bonnet or rear, etc. Is this possible with just an expression?

  • I remember something for two square objects.....x=(square1.x+square2.x/2)...y=(square1.y+square2.y/2) , could be usefull

  • I remember something for two square objects.....x=(square1.x+square2.x/2)...y=(square1.y+square2.y/2) , could be usefull

    Hmm, trying this, it's only creating the spark now and then, not sure mathematically what it's doing exactly?

  • C2 doesn't give that data. Here are some threads on the topic:

  • C2 doesn't give that data. Here are some threads on the topic:

    I noticed, isn't there a plugin that could do it, without using physics? Just to be able to place the spark on the correct side of the rectangle would be good enough.

  • The simplest method would be to use dummy detector objects.

  • The simplest method would be to use dummy detector objects.

    Yeah, thats what I'm thinking. Does pinning 4 detectors cause a big increase in resources?

  • granpa's code (almost) does it (brackets were in the wrong place):

    x=(square1.x+square2.x)/2

    y=(square1.y+square2.y)/2

  • The simplest method would be to use dummy detector objects.

    Sorry, I forgot to ask, is there an efficient way of creating the 4 detectors, and pinning them to the sprite at the different positions?

  • granpa's code (almost) does it (brackets were in the wrong place):

    x=(square1.x+square2.x)/2

    y=(square1.y+square2.y)/2

    Hmm, this doesn't seem to create the sparks at all now, before they created by at the same position as the car, but now they don't seem to be there? I just realized, I'm using tilemaps, so will I need to calculate it for the tile the car collides with?

  • Yes. R0J0hound's examples had a TileMap mechanism.

  • granpa's code (almost) does it (brackets were in the wrong place):

    x=(square1.x+square2.x)/2

    y=(square1.y+square2.y)/2

    oops.....I wrote that at 7 am my time on memorial day morning with one eye shut......

  • > The simplest method would be to use dummy detector objects.

    >

    Yeah, thats what I'm thinking. Does pinning 4 detectors cause a big increase in resources?

    Not unless you have a large amount of instances that need the dummies.

    The most efficient method would be to make separate objects for the detectors, and put them in a container with the object.

    Make as many image points as you need and label them sequentially, d0, d1,d2....

    Then on creation make a loop and place them at imagepoint "d"&loopindex.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yes. R0J0hound's examples had a TileMap mechanism.

    Trying this:https://www.scirra.com/forum/get-the-x-and-y-of-a-span-class-posthilit-collision-span-span-class_p1025697?#p1025697 adjusting the code to match my car, at the moment it's not resizing the masking box to the size of my car properly, and it's occurring on impact of the tile regardless of the tiles collision polygon, am I missing something?

  • Done, I created and pinned each detector sequentially in a big 16 piece event, pretty ugly but I'm not smart enough to do it with an efficient, dynamic loop :/

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