Guizmus's Recent Forum Activity

  • Joannesalfa

    Love this way of explaining a problem :)

    I would just add a "hash*t" boolean on the arrow set to true when it first hits, and add a condition "X arrow hash*t" on the collision detection. This way, you can let your arrow go through the mob without destroying it and not trigger any other damage dealing after the first mob.

  • Hey,

    The solution to change the max speed and use a boolean to know if dashing or not seemed to be the good way to go.

    Here are the parameters that are to be tested :

    • dashing speed : how fast the NPC goes when dashing
    • dashing duration : not really its duration, but the coefficient to apply to "deceleration" during dashing, as default settings would create a very short dash.
    • running speed : the base speed to go back to once dashing is complete.

    Now let's think about the events. If an input is detected, if it's "space bar" (example), then player dashes if he wasn't already. If it's anything else, he jumps.

    How to know when the dashing is finished ? I used the fact that the player speed was at that point below the running maximal speed (and had landed), so the transition should be smouth.

    Here is how it goes in a capx.

  • NodeAtX/Y is the coordonates of the Xth point in the path calculated by the pathfinder. I take the last one : the destination. -1 is because arrays in js are 0-based, first element is on index 0. It can never be less than 1, because you always have a destination if the path is found.

    Even if I made a mistake, let's say -2, it would return Null, equivalent to 0 I think in this case, the cross would be at 0,0, but the sprite wouldn't move, it wouldn't have any path to follow ^^

    You can now see where they are heading. I couldn't correctly debug your code without adding some correct debug. The enemies were going somewhere slowly, it took decades to understand the problem at first ^^

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here is a little capx with a simple 3 events 3 objects to do what you described :)

  • delgado

    Your problem was fun to solve :)

    I didn't move any origin point, but I use a "handle" point and a origin point. I also had to use the "relative angle" of the sprite, the angle from 0 degree (original angle) and the handle, to synchronise with the touch.

    here is the capx

  • I coded what I told you, then cleaned a little, and it's nearly another code :/

    capx

  • Well, I don't like problems I can't correct.

    So here is the debug. In the runtime.js of the pathfinding behavior, just add the following code in the behinstProto.oncreateFunction, once this.a is set (line 73) :

              this.inst.add_bbox_changed_callback(function (_this){

                  ?return function (inst) {

                        _this.a = inst.angle;

                  ?};

              }(this));

    I used what I learned from your code in particules plugin (the only one I found using the add_bbox_changed_callback function), but I didn't see any "remove_bbox_changed_callback", so I didn't know if and how to remove the eventlistener once the object is destroyed. Not finding the function in any other behavior made me think there was a more appropriate function, didn't find one though.

  • Hey DoudouSupreme

    Long time no see ^^

    I saw that you couldn't, also saw your "bug report" about it ^^ I'll send my mail.

    For your problem, please, upload a capx ^^

    The problem is event 61. You think you picked the volume with the condition "NPC Is overlapping Volume" when in fact you picked both. You have to pick the NPC first.

    If you don't, the overlapping condition will just pick the 2 NPCs and the 2 volumes (they are overlapping at first). Then, the NPC : Pick instance with UID will just restrict the picked NPC to the one you wanted. In the end, your "picking set" will be the 2 volumes and the NPC. I'm not sure what the function calling will send in Volume.UID, as there are 2. Not what you want anyway.

    Next, you could easily just change the Find Path parameters to :

    X : random(Volume.Width)+Volume.X

    Y : random(Volume.Height)+Volume.Y

    Making the NPC obligated to move inside the volume.

    Last thing, event 62, the function picks a volume, but no NPC is specified, so all NPC are selected. You have to add a second parameter to the function (NPC.UID) and select the NPC too in the function event. You could also forget about the volume.UID, as with the PathFinding I suggested, you should be able to pick the volume with the same "NPC is overlapping Volume" condition in the end of event 62.

  • Link to .capx file :

    https://www.dropbox.com/s/6b0lqvb8zb6cejh/bugPathFinder.capx

    Steps to reproduce:

    1. create a sprite with pathfinding

    2. during execution, change sprite angle

    3. calculate path/move along path

    Observed result:

    The sprite angle is reinitialized to its spawning angle before moving.

    Expected result:

    The sprite should start moving using its current angle.

    Browsers affected:

    Chrome: yes

    Firefox: yes

    Internet Explorer: yes

    Operating system & service pack:

    Windows 7 SP1

    Construct 2 version:

    r136

    ------

    Some personal observations after research in the behavior code, the problem is that the a variable (the angle of the object, store into the behavior) is set on creation of object, and then used in the tick function when isMoving is set to true (starting moving), if the rotation is allowed of course.

    But the behavior never calls runtime.add_bbox_changed_callback, never updating its inner angle (a), making it believe it never rotated, even if the sprite (or any over draw-able object in fact) called setAngle

    Hope this helps.

  • xoros

    Invisible sprite is a nice way too, you are right. More C2 friendly. A little less CPU friendly maybe, as the arrays in V8 are really fast.

    Though, the invisible sprite is a lot easier to manipulate, to rotate for multiple shape test for example.

    If, like you suggest, you create a "test Sprite" for each shape you want to test, and move it/rotate it everywhere possible within the flood generated shape, and test if the test shape is included in the flood shape at every step, you should be good too.

    Only difficulties are :

    • testing ALL possibilities. You'll have to use the basic tile size to minimize the possibilities.
    • testing if all of the testing shape is included in a minimum of events, because this test can be done a lot of times in a row...

    For simple shapes, other algorithm can be used, maybe more CPU friendly, but I don't see another method for testing any imaginable shape you want to create.

  • Darklinki

    Sorry, I tried to post screenshots from dropbox in an unusual way, they didn't make it ^^

    Here is the project, it's just my first real test on C2, no value, it can be easier to understand.

    Screenshot

    Capx

    Thanks a lot for taking a look !

  • Well, first of all, let's try not to test all the grid all the time. If your gameplay is based on switching 2 tiles (like most match 3 are), you should "just" test those 2 for shapes. In 2 steps then, first detect all the same color tiles, then detect if the current group makes a shape.

    1/ detect all the same tiles, it depends how you store your grid. I'll suppose you have an 3 dimensional array for it (X,Y for the grid, Z for the tile type/color). Best way to detect every tile would then be a recursive function, selecting currentTile, flaging it with a Boolean (so it's not re-analysed), and comparing its color to the 4 adjacent tiles. Run the function on every detected tile then, and collect an array of (tileX,tileY) during this function.

    You should then have something like this (let's say we detect a L shape) :

    [(5,5),(6,5),(5,4),(5,3)]

    2/ detecting the shape from the tile array returned

    First of all, find Xmin and Ymin in the array, and then substract it to every couple, so you have something like this for the current example :

    [(0,2),(1,2),(0,1),(0,0)]

    Next thing is a function that tests if a matrix contains an certain shape. A shape is described by another matrix, just like the previous one. The test is done by comparing if every couple of the shape is also set in the matrix to test. If the matrix to test is bigger than the shape matrix, you will have to test it multiple times with all the offsets possibles so all the matrix is tested.

    Don't go rotate the matrix or anything to test all the possible L orientations, just call again this test function with other shapes representing the L shape in multiple orientations.

    Repeat the 2/ with all the shapes you want to test, and you should be done.

    This seems really... heavy to code in C2. I personally would use a plugin for this if I did it.

Guizmus's avatar

Guizmus

Member since 26 Mar, 2013

None one is following Guizmus yet!

Trophy Case

  • 11-Year Club
  • x4
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies