Assigning a hat to a pedestrian - then killing him.

This forum is currently in read-only mode.
From the Asset Store
Kill The Zombies
$23.40 USD
40% off
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported
  • I need help once again. My marvellous invention that I call "PRE" (Pedestrian Randomization Engine) just failed me! When I finally got up to the point of adding dying pedestrians I noticed that their customized headwear / shirts change places with another pedestrians when I kill them!

    EDIT:

    Resolved! Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Firstly, your .cap is officially hard to navigate. Also, it's going to be hell if you add levels later on and want to make changes that permeate throughout all of them. You're better off including one (or multiple, for readability sake) event sheets that handle things in a more generic manner. That way if you want to make a change that affects multiple layouts, you only have to do it to the one event sheet.

    You can add event sheets not tied to any one layout by right clicking on the "event sheets" folder in the "project" bar. Then, in any layout's specific event sheet, right click and "include" the event sheet that the layout needs to use the events from. This will tidy up your event system, making it much easier to read, as well as facilitate modularity later on.

    As for your specific problem, in the properties of your civilian object, scroll down to the "container" option. "Add Object" and select PRE_shirt and PRE_hat or whatever the shirt and hat objects are called. This will tie the hat and shirt objects to each NPC individually --> multiple NPCs could have different shirts and hats, and if the controlling object (in this case, the civilian) is destroyed, so will the hat and shirt particular to him (but no others). I tested this, and it seems to be an improvement, you should be able to work out the remaining bugs from here (you'll probably have to change the flow of the events so that it takes this into account)... Still, if you have any further problems, shouldn't be too hard to fix.

    Your game looks pretty cool, at any rate. Good luck with it.

    Edit: I just worked out what one of the causes of a bug would be. Whenever you create a shirt or hat object, it also creates a civilian (because a container object is also contained by the object it is containing?). My suggestion is to not create the hat and shirt objects, but rather run the events that change their appearance on the creation of the civilian its-self. There are some complex problems associated with containers, and I fear you'll have to modify quite a bit to utilise them. Which is why generic event sheets are awesome!

  • Ahaha, I love how some people are just walking around naked

    Anyway Stargoat is right, you need some serious organization in your .cap. Make some object folders and sort your stuff, man. You can have a folder for Player stuff, NPC stuff, Background stuff, etc. It makes making events SO much easier because those folders get carried over to the event editor and you don't have to hunt through a few hundred little icons looking for the one object you want to make a condition for, you can just scroll to the folder it's in and look through like, ten objects instead.

  • Just had another look at the .cap. Pairing the pedestrian and their clothes and then changing...

    + MouseKeyboard: Key P is down
    -> System: Create object NPCPedestrian on layer "Gameplay" at (MouseX, 1061)
    -> System: Create object PRE_HatGenerator on layer "Gameplay" at (0, 0)
    -> System: Create object PRE_ShirtGenerator on layer "Gameplay" at (0, 0)
    -> PRE_HatGenerator: Set 'PRE_HatRoll' to random(PRE_HatGenerator.GetAnimationFrameCount)
    -> PRE_HatGenerator: Set animation frame to PRE_HatGenerator.Value('PRE_HatRoll')
    -> NPCPedestrian: Set speed to 60 - random(30)
    -> MageDeathbeam: Place in front of NPCPedestrian 
    -> PRE_ShirtGenerator: Set filter to RGB(random(256) -50,random(256) - 50,random(256) - 50)
    [/code:l051qzjt]
    
    to
    
    [code:l051qzjt]+ MouseKeyboard: Key P is down
    -> System: Create object NPCPedestrian on layer "Gameplay" at (MouseX, 1061)
    -> PRE_HatGenerator: Set 'PRE_HatRoll' to random(PRE_HatGenerator.GetAnimationFrameCount)
    -> PRE_HatGenerator: Set animation frame to PRE_HatGenerator.Value('PRE_HatRoll')
    -> NPCPedestrian: Set speed to 60 - random(30)
    -> MageDeathbeam: Place in front of NPCPedestrian 
    -> PRE_ShirtGenerator: Set filter to RGB(random(256) -50,random(256) - 50,random(256) - 50)
    [/code:l051qzjt]
    
    Seems to work perfectly, as far as I can tell. Lots of pedestrians spawn, but they did so in the un-modified .cap, so I assume that's how it's supposed to be.
    
    Just one other thing I'll point out... I checked the unlimited FPS for that layout, and I got but 100 frames a second. Considering my computer isn't terrible, that's getting pretty close to what I'd consider as the lower limit to the FPS you'd want to get. Might want to look into the efficiency of the .cap... in particular, you're using a lot of shader effects that might not be adding that much to the experience, but are still taking a massive toll on the video card.
  • Thanks guys, a LOT! This is why I love this forum.

    I'll tone down the shaders so it runs better. I tested the container method and it works perfectly.

    And yes, I suck at organizing stuff in events Actually I'm looking for a guy to make it a lot easier to work with because I suck at that kind of stuff. I'm a messy Constructor.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)