R0J0hound's Forum Posts

  • With a tilemap I don't think any of them will help, since all those get a collision shape either by using imagepoints or using the size and angle of the object to calculate the collision polygon. Tilemaps are different. For them to work we first need to find the tiles the player overlaps, then treat each tile as a separate object. It's doable, but I'm very slow at coding lately and I have other things I'd like to work on first.

    Another way to do it is to use a different approach. Instead of figuring out the collision polygon, we could use collision checks with moving around a little to find the approximate angle of the hit edge. The closet existing capx to that would be this, but it would need more work to get it to handle sliding on more angles.

    By far the simplest thing to do would be to just use the physics behavior, which probably would look alright.

  • bloodshot

    Just multiply the speed by an value between 0 and 1 when it bounces

    Set Yvelocity to -0.5*abs(Yvelocity)

  • It involves finding the angle of the spot on the polygon the player hit and canceling the speed moving against the object. You can look here for a few examples you may be able to use in your game.

  • tgeorgemihai

    You probably could do that with only two paster objects. One to paste a players view and then a second that you paste the views to.

    Use paster if the game has webgl on, otherwise it doesn't matter, you can use either.

  • One thing I see that would simplify the z-ordering is if you only did a hexagon at a time. Actually with that you could easily enough handle collisions and movement within a hexagon very simply. You could mask out everything outside the hexagon. This does introduce a different problem though, transitioning from one hexagon to another which is mainly a matter of changing the player's position. That the point I'm stuck currently, just need to come up with a clever way to do that.

  • 1.

    No it doesn't, either is just as fast.

    2.

    First C2 filters down the possible collisions with collision cells:

    https://www.scirra.com/blog/ashley/6/co ... on-in-r155

    Next it sees if two object's bounding boxes overlap, and then it sees if the collision polygons overlap.

    Basically it goes from fastest check to slowest and stops further checks if objects can't be overlapping. The more collision poly points the slower a check will be.

  • You could do that. If it's just a probability of happening or not you could just compare with one value.

    aka random(100)<40 for a 40% chance.

    If you want a probability of more than two things happening you would store random(100) in a variable first. So for example you want A to have a 30% chance and B a 10% you could do:

    global number rand=0

    every tick

    --- set rand to random(100)

    rand is between 0 and 30

    --- do B

    rand is between 30 and 40

    --- do B

  • mh11

    I've seen the question come up often and there are two solutions.

    One is to pick one object and store it's values in a variables and then in a separate event pick the other one and use the values to do something. One quick thing you can save to a variable is the object's iid then you can use expressions like Sprite(1).x+sprite(2).x to add the x values of two separate instances for example.

    Another more useful thing you can do is to make a family containing only that one object type, then in events you can pick two separate instances independently. If you use C2's physics you have to use the family route.

    viewtopic.php?f=148&t=91829&p=718895&hilit=rope#p718895

    With the chipmunk behavior it makes things simpler, you specify the uid of the other object to attach the joint to and avoids having to use a family or even picking at all if you want to design joints in the editor.

    https://dl.dropboxusercontent.com/u/542 ... test2.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • mh11

    I don't follow. How are you not able to to refer to them from physics? Guess I'll have to look at your other topic.

  • Zebbi

    I don't think so, the projection math is slightly different.

  • mh11

    1.

    The collision polygon isn't something the C2 usually lets you do, and the behavior just grabs from that. The only plugin i know of that let's you change the collision polygon is yann's polygon plugin, but I haven't tested it recently to see if it works well with the behavior.

    2.

    It's very simple with this behavior. Just apply a force at an offset. The offset can be any point on the object and applying multiple forces work as expected

    For what you're actually trying to achieve the best current solution is to join all the objects together with physics joints, but even then it can't be completely rigid. A proper solution where all the joined objects form one rigid object is possible with the box2d or chipmunk libraries themselves, but nothing is exposed to C2 for design reasons. The question to do it has come up before and my proposed solution then was to use the chipmunk library with js instead of the behavior.

  • Global and local variables are some of the best features of c2 in my opinion. Dictionaries have their uses but I seldom need to use them.

  • No thoughts other than that looks complex. It probably doesn't need to be.

    The idea I presented basically points a sprite in a direction and increases it's width until an object is hit. That gives the hit object and a point of collision.

    Yours seems to set the sprite to be full length first and then add all the overlapping objects to an array, then loops over the array in some way while shortening the line by halves. So I'm guessing some kind of binary search? I guess I'd have to look at the tutorial you reference. My guess is the issue may be the order of the sprites, but really there is no way of knowing without something to test.

  • oosyrag

    I meant it to be 10 pixel intervals:

    ray: set width to 10*(loopindex+1)

    So the furthest a ray would be able to go is 100*10 or 1000 pixels which is fine for stuff on screen with a res of 640x480. Best case it would check for collisions once, and worst case it would check for collisions 100 times. It's the difference of hitting something close or nothing at all.

    If you're curious here's a more advanced example that also can be tweaked:

    https://dl.dropboxusercontent.com/u/542 ... laser.capx

    The laser in it has a range of 1000 pixels and only checks for collisions 10 times if nothing is hit. It's progressive so it finds the hit point with a 1/1000 pixel accuracy. The worst case is around 50 collision checks if it hits an object near the 1000 pixel range, but typically it's much lower.

  • I can't open your capx because it uses a plugin I don't have installed currently, and I'm lazy about installing plugins.

    It sounds just like a picking issue, namely picking two different instances of the same object type. You can find solutions for that elsewhere on the forum. One thing you could do instead is loop through the list objects and save the current selection to a variable so the next one would have a value to compare to.

    To have multiple independent rows you could pick by y first then loop over them by x.

    https://dl.dropboxusercontent.com/u/542 ... _list.capx