R0J0hound's Forum Posts

  • 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

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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

  • Simpler than that there is bullet behavior property "set angle", that will do what you want if it's set to no.

  • Here's the basics of how to do it. It can be further refined to be more precise and you can use a family instead of wall to hit more object types.

    Add a Sprite to your project and call it Ray. In the image editor put it's origin on the left-center and add another image point to the right center. Once on the layout, make it's height 1.

    Every tick

    --- ray: set position to player

    --- ray: set angle towards (mouse.x, mouse.y)

    Repeat 100 times

    --- ray: set width to 100*(loopindex+1)

    [sub event] ray: overlaps wall

    --- stop loop

    --- ray: spawn explosion at imagepoint 1

    --- wall: destroy

  • Zebbi

    I suppose that would be helpful. I have an example earlier in this topic that did that somewhat. I don't have an exact example using this effect though. Currently I don't use effects at all, and I haven't used rex's behavior. In a nutshell it's because webgl is slower on my machine if used and I need to modify C2's runtime to actually be able to use it, so I don't.

    I have had a go at non effect version, a week or so ago, which may or may not be useful. It uses the paster object instead, but it does follow the pattern where the game map is defined on the "map" layer. That is where everything is moved around and everything from there is mapped to a 3d perspective.

    The events have three parts to it. The "position objects" section, which would be similar to what rex's behavior does, except it also calculates the relative angle of other objects so the correct frame is used. The "ground render" section is what the mode7 effect does (however there's a math error in there I haven't tracked down yet). Finally the "control" section controls the movement in a custom way that I liked.

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

    Rabbit trail aside, that was after a week of tinkering and I'm at the point where I need to rework the math to correct the ground texturing alignment. Even with the effect and the behavior there would be work to match things up imo. Even though this is thought of as pseudo 3d, in reality it requires full on 3d math with perspective transformations.

    A very useful reference is here:

    http://www.coranac.com/tonc/text/mode7.htm

  • Zebbi

    If the objects are in a container, the other would be created automatically. And yes you could just use variables instead of a second object if you wanted.

    Basically you can set it up any way you want. The ideas I have should work, or the ideas you're presenting would also work. In the end you only need one object type that is positioned on the mode7 plane. Anything else is purely for convenience or just to make other things easier to do.

    Having two objects in a container for instance makes collision detection actually possible. Consider if you had only objects on the mode7 plane, how would you do collision detection? You could try using the overlapping conditions, but really you'd get bad results. By having another object in a top view perspective, you can do collision detection with them in an easy way, plus all the movement behaviors can be used there.

  • Just to clarify a few things:

    The distance an object moves per frame is speed*dt, so with a speed of 5000 the object will move 5000/60 or about 83 pixels per frame, which is why it can pass other objects without colliding.

    For doing an instant hit, the common approach is called "ray casting", but you can also find examples on the forum about lasers that do it too. By using a sprite and changing the width you can do the same thing as the line segment idea.

    That error is a bug I'd say, and a good candidate for an error report.

    Your last issue is probably something simple, but we'd need to see a capx to find it. The posted events don't seem to cause it.

  • It is possible, I didn't say it wasn't.

    Put two objects in a container, Sprite and SpriteMode7. Position the Sprite objects in the layout editor to define the object positions. Then in the event sheet use the behavior or whatnot to set the SpriteMode7 object's position from the Sprite's position. You then move around the Sprite objects and the SpriteMode7 object will update accordingly.