A few small questions

This forum is currently in read-only mode.
From the Asset Store
Various Bell Sounds (from small to huge) / 35 Unique Clips / 2:46 minutes of audio
  • I have a couple of questions which I haven't been able to figure out for the past 2-4 hours. The first deals with .ini files, and more importantly, how to incorporate them. The second deals with changing objects, simply put. Lastly, the third is about trying to randomly select a number, etc for some simple "if" statement equivalent.

    Because it makes more sense in my head, I'll do this backwards, and start with three. I have a bit of experience working with Python, and could easily do this if I were just doing python. But, since I don't know how Python and Construct work together, despite this nifty guide.

    Could someone show me how I could go about generating a number between 0 and 2 (ie 0 and 1, if I remember correctly), and assigning this to a variable which Construct would allow me to use in another event? What I want it to ultimately do, is determine whether Team 1 or Team 2 gets the ball.

    Which leads nicely to the second question. How do I go about changing an AI object to the Player's control, so that the object can then be moved via keyboard? Do I simply delete one object and spawn another in its place, or is there a better way to do it? My only concern here is that if the object is tilted 90 degrees and then I do the spawn/destroy method, the object will spawn in default position. Needless to say, this looks jerky. I can live with it, but if there's a better way, I'll take it.

    My first question goes into how I can use a .ini file to import character data, and then use it within Construct. Things like using their assigned Speed value to dictate how fast the object moves, or using their Shooting skill to do a simple calculation against the goalies Catching skill. Furthermore, is it possible to overwrite a single value in an already present .ini, without mucking around with the entire thing? As in, upgrading Joe Smiths level/stats, without screwing up John Doe and Jane Baker.

    The Wiki really helped me understand the What, but now I'm just stuck on the How, I'm afraid. Thanks in advance, and goodnight. Maybe I'll sleep before the sun comes up. Blasted Construct, eating away my night!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Could someone show me how I could go about generating a number between 0 and 2 (ie 0 and 1, if I remember correctly), and assigning this to a variable which Construct would allow me to use in another event?

    All you have to do is set the variable (either a global or an object variable) to random(2). random(a) returns 0 to a-1, so in this case it will choose 0 or 1. If you pass a whole number it will return only whole numbers. If the number has a decimal it will return a random float from 0 to a-1.

    Which leads nicely to the second question. How do I go about changing an AI object to the Player's control, so that the object can then be moved via keyboard? Do I simply delete one object and spawn another in its place, or is there a better way to do it? My only concern here is that if the object is tilted 90 degrees and then I do the spawn/destroy method, the object will spawn in default position. Needless to say, this looks jerky. I can live with it, but if there's a better way, I'll take it.

    It doesn't look jerky if you set it up well. You can modify object properties when they are spawned, so setting the angle to the AI angle on the frame it spawns will look like a flawless transition. You could also set up a variable called playercontrolled to make it so the ai becomes player controlled when the value is 1 instead of destroying it and spawning a player object. It's your call.

    For ini files, there are write value actions, and read value expressions. The write actions just write a value to an item in a group. The ini only writes or reads where you tell it to write to. So for instance you can have a skill value for your goalie whose value is set to the ini's value "catchskill" in group "goalie". At the start of the game you could set all the players skill values to the corresponding ini values. You could even have different ini files for each team, so you can save and train teams or whatever.

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