dop2000's Forum Posts

  • 1.) Those changes are very helpful and have increased performance dramatically, thank you. However, on overlapping rather than behaving as solid, when I change the units to divide their distance equally within their group, is that going to stop other units in other groups from crossing individual units within the first group?

    2.) The collsion checks don't need to be checked for every instance on the map, providing collision isn't an impassable (cliff/building) and would prevent pathfinding to detect it which would cause units to either go over/through it (with overlapping) or go to it and then need to recalculate pathfinding to go around it, which would look horrible and be inefficient.

    Sorry, I read these questions multiple times, but still don't understand them.

    Could you explain what all these triangle objects will be doing in your game? And why do you need to check if they collide with each other.

    3.) Although your solution works well, is my original method feasable? And if it is, I'm sure it could combind it with your solution.

    How did you learn about the skipping unnecessary checks?

    My solution is basically the same as your method. On tick 1 collision is checked for the first 20 instances. On tick 2 - for the next 20 instances. And so on.

    Run the project in Debug Mode. You'll see the number of collision checks is much lower when instances are spread and increases when they all move to the same point.

  • I tried Browser-> Execute JavaScript:

    var global = Function('return this')(); 
    
        document.onkeydown = function(){
    
        if(window.event && window.event.keyCode == 116)
                { return false; }
        }
    [/code:266tm0v5]
    
    It works, but only in Chrome.
  • You only asked how to save a value, you didn't ask how to load it <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    This is the bare minimum code:

    Also, have you tried googling? There are plenty of tutorials with good examples of using the local storage:

    https://www.scirra.com/tutorials/all

    In your capx you are not saving high score in Local Storage! You are saving and loading the entire game.

  • Do you really need to check for collisions between all 2000 instances? Cause that's millions of checks every tick, and I don't think any optimizations will help in this extreme case..

    I made some changes to your file, have a look:

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

    You should only use "Is Overlapping" with this method, don't use "On collision".

    And, of course, the more objects are added, the less often overlapping checks are performed for each of them, so the accuracy of collision detection will decrease.

    Also, interestingly, when instances are spread on the layout, the number of collision checks is lower, than when all instances are in one spot. I'm guessing the engine is skipping unnecessary checks for objects that are too far away from each other.

  • You can also run your game in Debug Mode and check the actual number of collision checks.

    C2 games can run smoothly even with thousands collision checks performed every tick.

  • Your capx requires several third-party addons, one of which is commercial.

    If I understand correctly, you added a second character object and it's causing all kind of problems.

    I think it would be much easier to have just one character object with multiple animations.

    Your animations can be like this:

    AssassinIdle

    AssassinRun

    AssassinAttack

    GnomeIdle

    GnomeRun

    GnomeAttack

    Also, add an instance variable "characterType".

    As a result, you should be able to add new characters to your game with very minimal changes to your events.

    For example:

    On Space key pressed -> Character set animation to self.characterType & "Attack"

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Local Storage -> Set item "MyValue" to myGlobalVar

    That's it.

  • Yep, see this post:

    But I don't speak Portuguese.

  • Here is a very basic example of wall sliding:

  • I think this post should be added to the FAQ, it's super useful:

  • You got me. I don't know

    Maybe move the player to the building layer when it goes inside. And then move back to MAIN layer when it exits.

    You will need to make the entrance and exit wide enough for the player and make these areas quite dark, to make the switching between layers less obvious.

  • To add to tarek2's answer:

    Your code works, but you can do it much simpler:

    System: For "" from 1 to VAR -> Create object Sprite on layer at 360, 450 - 40 * LoopIndex

  • Then yes, collision probably happens between the frames.

    I would pin another invisible box to the player ("PlayerFallingBox"), the same width as PlayerBox, but 3 times higher.

    And use it to detect collisions with enemies when the player is falling.