Rable's Recent Forum Activity

  • Here is the link to the simplified capx :(seems like the forum removed the link... Maybe you can help based on the description below?)

    ok, workaround : to download the capx, just enter

    dropbox.com/s/4ibtr46yhpy8avd/project88_debug.capx?dl=0

    with something at the beginning of the adress

    Curiously, the symptoms are different now, but there is still a bug with the "set width to enemy.health" action. The health bar just keep its default size and isn't resized.

    I found out another cusious thing : I defined a global variable named "level", and added an event :

    if "level" = 25 (default value) play the events.

    If I remove this condition of "if level=25", everything works fine ! The problem is that I need it, as I would like to create different enemies in regards to the level...

    ---

    Edit :

    As it seems like I can't post links, here is the detailed events and actions

    enemy has instance variable Health put to 100

    lifebar has width of 50

    global variable "level" = 25

    Event sheet 1 :

    start of layout :

    delete enemy

    delete lifebar

    include eventsheet2

    ---

    eventsheet 2 :

    if level=25 :

    create enemy

    create lifebar

    put lifebar width to enemy.health

    ---

    the result :

    it creates enemy, it creates the lifebar, but lifebar's width is still 50, not 100.

    If I remove the condition "if level = 25", everything is fine and lifebar's width becomes 100...

    (removing the "destroy" actions at the start doesn't help)

  • Can't do it right now, but I will do this ASAP.

    Thanks !

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The health variable is an instance variable so its base value is not defined in the code but on the object. The variable call by the healthBar object is done after destroying the enemy, as the destruction occurs at the start of layout.

    The include sheet is in an "every tick" + "trigger once while true" event that is placed just after the "at the start of layout" event, in order to create the objects I need immediately after destroying all the objects that I don't need.

    Thanks !

  • Hi everyone,

    I have a strange bug occuring in one of my project. I simplify everything but it stands like this :

    ---

    object type Enemy has Health instance variable defined to 100 (default value of the object type)

    start of layout:

    • destroy Enemy

    (inside an included event sheet)

    create Enemy

    create healthBar

    set healthBar width to enemy.health

    ---

    At that moment the Enemy health value is 0 (checked in debug mode)... Which shouldn't be the case, as I never told the code to put it to 0.

    I created a new project, entered the simplified code, and it works fine ! Enemy.health is 100, and it sets healthBar width to 100. Just in my bigger project, it doesn't work, and I can't understand what's happening.

    I found two workarounds :

    disabling the event "destroy Enemy" at the start of layout makes the health be 100 at the moment the healthBar needs to read its value.

    adding "set enemy health to 100" before setting the healthbar width also works.

    I already looked a couple hour for the solution, but I can't find any spot in my code where I ask to put the enemy's health to 0. Moreover, by not destroying the object at the start it works just fine.

    Any idea of what's happening?

    Thanks !

  • This is great news ! Thanks a lot !

  • Thank you codah, and sorry for the misunderstanding.

    My original problem was this one : (not allowed to post URLS but check post "Question about using a single event sheet on different level" - last replied wed 27th august 2014 at 6:26 pm)

    What I meant with the number of instances is the following : if I have instances 0, 1 and 2 on layout 1, and I'm currently on layout 2, where there is 3 additional instances of the same object type, will they be numbered 0, 1 and 2 - or - 3, 4 and 5 (IID)

    And so instances awaing for me on layout 3 will be IID 6, 7 and 8?

  • My first goal was to provide a clear way of dealing with the post's original problem : using IID in a more "durable" way.

    I don't have access to C2 right now and would like feedback on the solution I'm providing : is something wrong with the logic, or is there a better way to do it?

    Then I wanted to learn about things that I haven't been able to find informations on until now :

    • Do loops in the "at the start of the layout" condition really loop, or just play once?
    • Is IID dependent on the # of instances on layout or on the project? No informations on that point in the manual...

    The actual thing I can't do : if the IID are #4, 5and 6, how can I "tag" them with a number instance variable 0, 1 and 2? i.e. is there a way to select the instances with the lowest IID on the layout, then select the next one, or the one with the highest IID, in order to be able to tag them correctly.

  • Undigging this one but I have a similar problem and hopefully just found a solution.

    Could this work? :

    (considering the "object" object type has an "index" number instance variable, and that there are 5 instances of "object")

    at the start of layout

    Repeat (5)

    pick loopindex instance of object (pick Nth)

    set variable object.index to loopindex

    From now on, you can start using the "index" instance variable as if it where the instance's IID, as it won't change throughout the layout. Not 100% sure that a loop at the start of layout will play... (anyone know?) but if it don't, it could be put in a group that triggers only one.

    I also have another question : is the IID of the first instance on the layout always 0, or, if there are other instances of this object still alive on previous level, would the first instance on the current layout be more than 0?

    And if it could be more than IID 0, is there a way to still give them correct "index" numbering, i.e. : 0, 1, 2, 3, 4, etc...

    This would require to take the instance with the lowest IID and assign the 0 number to its index instance variable, but I have no idea how to do it... Anyone knows?

  • I can't believe it ! It's working like a charm ! Thank you so much !!

  • Hi everyone,

    I need some object instances to act differently. They behave exactly the same, even though I put a lot of random number on them.

    For example :

    wait 1+random(4) seconds

    All instances will always wait the exact same amount of time. Is there a way around this, and making the instances actually wait each one a different random time?

    Thanks a lot !

  • Thanks for the (very !) quick reply, DuckfaceNinja.

    1) Ok, I guess I'll continue with different object types. I thought I read somewhere that the game has to load each sprites for each different object types, even if the sprite used were the same. Is it true? If it is so, using object instances seems a better solution but I just can't find a way to make them do what I want and selecting the right one easily.

    2) I should have specified that I'm already using event sheet includes for my character (as well as enemies). The first solution you propose ("Put the mechanic in separated event sheet. While storing unique variables/event in the layout event sheet.") seems not useful in my case, as nearly every event refer to a specific enemy name, thus making it not worth using includes. I'm sorry but I don't really understand your second solution. Is it something to change in the project properties or the preferences? If so, I don't see where... Could you tell me more?

    I also tried to regroup my enemies into families, but it didn't really helped so far...

    Among solutions I tried to find, I thought about creating 4 global variables "E1", "E2", "E3" and "E4" and changing the value of the variables at the beginning of each level. For example : global variable E1 = "ninja1", E2="ninja2" for the first level and change the values to "warrior1" and "warrior2" in the second level, then replace the "ninja1" object by E1 in the character event sheet, hoping it would select different object types... But it don't seem to work... Maybe this is just not possible.

  • Hi everyone,

    I'm quite new to Construct 2, I started learning it about 1 month ago and it's really an awesome tool !

    I started my first project and despite I read 100% of the manual, I still have some troubles for things that I thought would be simple. Here is my problem :

    In my game project I have a character on the left side and 4 enemies on the right side, dispatched as follows (consider -------- are spaces) :

    • -----------------------------E1-----------------------E3

    Character

    • -----------------------------E2-----------------------E4

    I want the character to attack Enemy 1 or 2 a random. If the target is dead he will attack the enemy on the second row (i.e. E3 if enemy 1 is dead or E4 if enemy 2 is dead). Nobody moves. Until here it's very easy. My problem is that I have a good tenth of different enemies that I would like to be able to place wherever I want across tenths of levels. Moreover, enemies have very different sizes and shapes, and often overlap each other, making it difficult to pick an enemy by specifying a single point on screen which it overlap. So I have 2 questions that I'm really scratching my head with :

    1) Should I use object instances when there is 2 (or more) times a single enemy on the screen? Up to now, my answer was "no", and I used 4 different object types because I felt it would be complicated to pick the correct object instance (and enemies also have random actions that they perform all together when using instances), while it's easy to copy-paste the events to make new object types. Or is it something that I'm missing?

    2) Most importantly, how can I specify which enemy the character should attack without rewriting its full event sheet for all levels (as there will be different enemies on each of them). For example, if I have two ninjas in the front row which I name ninja1 and ninja2, it's easy to tell the character to attack ninja1 or ninja2. If on the next level the two enemies on the front row are warrior1 and warrior2, how could I tell my character to attack one of these two guys without rewriting my character's event sheet for each level?

    Thanks a lot for your time and help !

    Pablo

Rable's avatar

Rable

Member since 6 Aug, 2014

None one is following Rable yet!

Connect with Rable

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

15/44
How to earn trophies