Nabu's Forum Posts

  • Ok, I was a little bit confused so I misread some things. Thanks to you !

  • Hello,

    I'm pleased to study a bit you capx and work around with Multiplayer plugin for tests. One thing remains obscure to me : in the "enemy" part, which seems to be shared by both host and peer, you gave a random point for the enemy patrol behavior ai. I don't understand how this does not conflict with multiple connected instances of the game. I mean, is the random function already synched when in multiplayer for secure random number generation ? (Or do we have to program this by ourself ?) I saw that it works, but why ? Why this function does not return different values ? And why it is done on the peer instance ? This should be only on the host that make all the calculations and send to peer via multiplayer messages or synched objects, although I know there's many ways to implement game logic in multiplayer (like host does main calculations and send results, or host and peer have the same simulation synchronized by functions, etc...).

    Is it because the TankBase is synched so when you do a modification, it's done once ?

    I saw that you disabled a random angle set at Projectile object creation. Is it for the same reason ? Because the object is not synched, so you can't use random function and set the spawner object's angle to be sure it shared ?

    I miss something. Do you have some time to explain me more ? I feel lost ! The multiplayer plugin is the most difficult to deal with in Construct 2.

    By the way, thanks for your useful template !

  • Hello,

    "Every X seconds" doesn't work per instance, so if you want several objects of the same type or family firing, only one will.

    You can add an instance variable (named "timer" for example) and at every tick (or every x seconds), for each object, add dt (in system expression) to the timer. In the same time you check if the timer is higher than a value, and if it is, you can fire.

    • Add a "timer" instance variable for your object.
    • Every tick => for each object => add dt to object instance variable timer

    - If timer is higher than value : can shoot.

    I hope it's clear enough. Sorry I don't know the Rexrainbow's timer plugin.

  • Hello,

    First I'm sorry to post this in the general discussion, but I've already posted three times a similar topic in the bugs section that was moved in the closed bugs. The problem is related to creating objects with physic behavior on the fly. As seen in this topic https://www.scirra.com/forum/physics-error-and-crash_t150137, other people encounter the same bug, and it seems to be not linked to how many objects you create even though the bug occurs more often with many objects created.

    After testing, and reading others comments and experiences, I'm pretty sure it's not the "way" asm.js is programmed, but a memory leak.

    So I posted here because Ashley closed the topic each time with no more explanation and we can't discuss any more about and maybe find a solution.

    If someone is interested, we can go further together. It's a big issue for me as I'm working on a commercial project and at the moment I'm stuck on this (it crashes the program).

    Thank you all for your time.

  • Ooh... So why do we encounter the problem when there's only few objects in game ? I really don't think it comes from the memory limitation, but rather a memory leak.

  • Problem Description

    Physics behavior bug / crash when creating objects on the fly. Possible memory extension fix in beta r209 did not fix the problem, and does not help to support more objects.

    Attach a Capx

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

    Description of Capx

    Simple layout with physic objects. Left mouse click to spawn coins high rate.

    Steps to Reproduce Bug

    Just spawn some objects with left mouse click, (hundreds of them, it's fast) and the crash will happen.

    Same capx from previous bug report.

    Observed Result

    App crash with physics behavior related debug data.

    Expected Result

    Being able to support more objects. The problem also shows with tilemap with physics behavior.

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (YES)

    Operating System and Service Pack

    Windows 7 SP1

    Construct 2 Version ID

    Beta r209

  • Ok, thanks for the fix and explanations. In some projects the bug is still here when there's only few objects though.

    After testing, the problem is not solved. I still get bugs with physic objects created on the fly.

  • When you select a layer, don't you have the "Locked" property under "Editor properties" on the left ? Or the lock buttons amoung the others in the layers tab toolbar on the right ?

  • Hello,

    Here's how to do that : https://www.dropbox.com/s/mb8oxg5zgnis9wt/spawnEnemyOnScore.capx?dl=0

    You can search and use the Rex's Nickname behavior to create object by a nickname you set on each object type that had this behavior, so have a different one for each object type in your family. In a cleaner way and fewer events.

  • There are plenty examples here https://www.scirra.com/forum/how-do-i-frequently-asked-questions_t63692.

    Here is a little one. I can show you more if you want. Click on the conditions and actions and "back" to see how I've went to it.

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can have two object types with same graphics and variables / behaviors. One being set as an obstacle to the line of sight, the other not. So when a tile is or become higher than the player, destroy it and create the same but of the type that blocks line of sight. You can encapsulate everything in function to make it clear.

    And maybe you'll be interested in ray casting (search in forums) for testing if player has direct line of sight to something. It can be customized (customised ?) to collide with what you want and thus have different kinds of obstacles.

  • There is no "facing" condition. You have to check wich animation the player is actually playing if you have one for to go left and one for right.

    Add a condition, select your player, under "animation" select "is playing" and the animation you want. For example, if animation "left" is playing, then shoot left.

    I can make you a little example for these kind of tests.

  • Of course, when the player shoots (I don't know your implementation, maybe post your project, or a simple one), I imagine you do the action "player => spawn bullet, or system => create object Bullet at Player.X Player.Y", just after this line in the editor your click on "Add action" and "bullet => set angle of motion to Player.Angle".

    In the editor you can quickly retrieve variables (like "Player.Angle" from objects with the little window that opens when you create or edit an action or condition.

    Or if you game is a plateformer, barely the same : spawn bullet, then create a condition "if player is facing left (by testing its angle or animation) => set bullet angle to 180 (left)", create an "else" condition and "set bullet angle to 0"

  • Yes, and the Pin behavior has nice effect like "hook" or "bar" to follow your character.

  • Hello,

    Here's things you can do :

    • use a boolean instance variable for your object, setting it to false when it dies and check for it when interaction. So during any interaction action, if it's dead, do nothing. It does not reduce the amount of object though. You can also disable collision for the object so it does not trigger anymore and saves a bit of cpu.
    • Using the Paster or Canvas plugin, maybe you can create a paster on a layer, the size of your layout and paste on it the sprite when it dies and destroy the object. But you can do no interaction with the dead object after this.