Well, I was thinking primarily in terms of indices. I never want to access element -1 of an array. It gets a little different when you're talking about spatial coordinates.
Welp, as I attempt to quash out my final bugs before release, I came across what may take the cake for new dumbest bug-fixing I've ever done.
About a week ago, I added drum fills, mediated by how high the drum slider is. If the slider is low, the drums will probably just groove. If the slider is high, the drums can kick off fill after fill after fill.
For some reason, this would sometimes crash out and give a nullreference. Now, also the music generation can occasionally crash out, which sucks, but I think that's just because it's like a billion things at once going on, and one of the things that happens is sometimes it gets ahead of itself and tries to play a note before that note exists. I've tried to track that one down pretty much forever and I can' find what causes it to happen or where exactly the problem is, and I've never seen it happen in the build, only the editor.
I assumed that the drum thing was basically the same... in order to do a fill it has to swap out some linked lists, and after the fill has to swap out some more linked lists to get back. So I basically am assuming that when there's an error, it's just it going "Oh wait I'm trying to play the next note but the lists didn't swap out fast enough so there's nothing there yet".
So I add in a little "Hey while this list is null, just beat, then resume when the list is loaded". And... sometimes it then just instead of the fill beats for the entire fill. Which is... not what it's supposed to do.
So then I finally do the smart thing and go "Ok, when one of the lists is null, just tell me which one it is so I can at least track this down".
It's the Bass Drum. It's always the Bass Drum. Well that's weird. I wonder if.... no I wouldn't be that stupid....
At run-time it populates the fills with the linked lists that contain the fill data, and one of the fills had two HighHat lines, and no Bass Drum line. So of course in the event that the drum picks a fill and it happens to be that fill, there's no Bass Drum node because there's no bass drum list in the fill object. Because I'm an idiot.
Change "HH" to "BD" and bam, everything works perfectly. I've had it running in the background for like 10 minutes now on free play, with the drums turned up to 10 and it's happily filling, grooving, filling, whatever with no problems.
For some reason, I desperately want to play this in VR!
I've got an opportunity to have my own 10x10 corner for pretty cheap for an event coming up this summer and I am seriously considering taking up the offer for 2 days playtesting and promotion.
I would love to have a chat about your experiences if you've hosted one or been involved with one. Hit me up via PM. Thanks!
I've got an opportunity to have my own 10x10 corner for pretty cheap for an event coming up this summer and I am seriously considering taking up the offer for 2 days playtesting and promotion.
I would love to have a chat about your experiences if you've hosted one or been involved with one. Hit me up via PM. Thanks!
@HallowedFaith I haven't done one personally, but my business partner has shown off our game at a few local conventions. I could put you in touch?
Welp, as I attempt to quash out my final bugs before release, I came across what may take the cake for new dumbest bug-fixing I've ever done.
About a week ago, I added drum fills, mediated by how high the drum slider is. If the slider is low, the drums will probably just groove. If the slider is high, the drums can kick off fill after fill after fill.
For some reason, this would sometimes crash out and give a nullreference. Now, also the music generation can occasionally crash out, which sucks, but I think that's just because it's like a billion things at once going on, and one of the things that happens is sometimes it gets ahead of itself and tries to play a note before that note exists. I've tried to track that one down pretty much forever and I can' find what causes it to happen or where exactly the problem is, and I've never seen it happen in the build, only the editor.
I assumed that the drum thing was basically the same... in order to do a fill it has to swap out some linked lists, and after the fill has to swap out some more linked lists to get back. So I basically am assuming that when there's an error, it's just it going "Oh wait I'm trying to play the next note but the lists didn't swap out fast enough so there's nothing there yet".
So I add in a little "Hey while this list is null, just beat, then resume when the list is loaded". And... sometimes it then just instead of the fill beats for the entire fill. Which is... not what it's supposed to do.
So then I finally do the smart thing and go "Ok, when one of the lists is null, just tell me which one it is so I can at least track this down".
It's the Bass Drum. It's always the Bass Drum. Well that's weird. I wonder if.... no I wouldn't be that stupid....
At run-time it populates the fills with the linked lists that contain the fill data, and one of the fills had two HighHat lines, and no Bass Drum line. So of course in the event that the drum picks a fill and it happens to be that fill, there's no Bass Drum node because there's no bass drum list in the fill object. Because I'm an idiot.
Change "HH" to "BD" and bam, everything works perfectly. I've had it running in the background for like 10 minutes now on free play, with the drums turned up to 10 and it's happily filling, grooving, filling, whatever with no problems.
For some reason, I desperately want to play this in VR!
I actually got a Vive specifically so I could test out doing it in VR, and I still want to maybe add that, but I had to have it finished by today and there were other, more important things, so I never got around to even testing out to see if it would work. I assume it would, I just need to enable it and try.
I've got an opportunity to have my own 10x10 corner for pretty cheap for an event coming up this summer and I am seriously considering taking up the offer for 2 days playtesting and promotion.
I would love to have a chat about your experiences if you've hosted one or been involved with one. Hit me up via PM. Thanks!
I've done a bunch of trade shows for software that is much more boring than games. And my biggest piece of advice is to come with a partner. First because setting up and paperwork and travel is boring but mainly so there is someone to watch your stuff while you go take a leak. And that way you can engage with more than one person/group at a time.
If you want your booth to look good you will need to get a bunch of stuff printed (before the day of because shit always goes wrong) and you will want to spend some money on some handouts with your branding on them.
You should go do it though, you can't really screw up. Worst case scenario is you was a bit of money and time but you will usually have a good experience.
I've got an opportunity to have my own 10x10 corner for pretty cheap for an event coming up this summer and I am seriously considering taking up the offer for 2 days playtesting and promotion.
I would love to have a chat about your experiences if you've hosted one or been involved with one. Hit me up via PM. Thanks!
I have had a booth at PAX before for InFlux. It was a big ol' success, but it would have been less so if I hadn't paid great heed to this Brendon Chung blog post on boothing. And absolutely have one or two other people helping out around the booth. Set up multiple machines so multiple people can play, etc.
My booth looked like this:
3 PCs where people could play a nearly-done build of the game on 360 controllers, and the TV is just looping the trailer. A hidden laptop is cranking the soundtrack through some massive old speakers so people walking by can hear (players have optional over-ear headphones). All 3 machines were pretty much in use the entire 3 days so I guess we could have used another. The table the PCs are on is an ugly one so the tablecloth was a must
Finally got eyes looking how I want (thanks to Matt Hoffman, Matt Wood and Ken Birdwell). We've copied the HL2 approach of not having any actual eye spheres, just a fancy shader that handles the look direction and can work on basically a flat plane stretched between the eyelids. I made it into a component and now I can effortlessly get good eye contact/behaviour on any actor, way more easily than with eye spheres and bones. Super psyched. Here are tests on my Third Guard character and the gman (all in ue4).
I've got an opportunity to have my own 10x10 corner for pretty cheap for an event coming up this summer and I am seriously considering taking up the offer for 2 days playtesting and promotion.
I would love to have a chat about your experiences if you've hosted one or been involved with one. Hit me up via PM. Thanks!
I have had a booth at PAX before for InFlux. It was a big ol' success, but it would have been less so if I hadn't paid great heed to this Brendon Chung blog post on boothing. And absolutely have one or two other people helping out around the booth. Set up multiple machines so multiple people can play, etc.
My booth looked like this:
3 PCs where people could play a nearly-done build of the game on 360 controllers, and the TV is just looping the trailer. A hidden laptop is cranking the soundtrack through some massive old speakers so people walking by can hear (players have optional over-ear headphones). All 3 machines were pretty much in use the entire 3 days so I guess we could have used another. The table the PCs are on is an ugly one so the tablecloth was a must
I've got 3 playing stations planned w/headphones. Didn't even think about the soundtrack being played at the booth, that is smart! Appreciate that link, will totally give it a read.
Finally got eyes looking how I want (thanks to Matt Hoffman, Matt Wood and Ken Birdwell). We've copied the HL2 approach of not having any actual eye spheres, just a fancy shader that handles the look direction and can work on basically a flat plane stretched between the eyelids. I made it into a component and now I can effortlessly get good eye contact/behaviour on any actor, way more easily than with eye spheres and bones. Super psyched. Here are tests on my Third Guard character and the gman (all in ue4).
Middle mouse button summons help topic for any command you on, opens a script if you click on that, and if you happen to reference an object in code, it will again open that up. It is an immense timesaver that I learned about months too late
I would also encourage you to learn exactly what version of gamemaker you have at the moment so that you do not gallantly go charging off onto a project you can never complete.
The input manager in Unity could use some work. It's where you map inputs to axes, but look at this:
You might expect to be able to use wasd, the arrow keys, or the joystick's 6th axis.
Nope. The "Type" field, 3/4 of the way to the bottom, is set to Joystick Axis. So the keys don't work. It's not broken, but it is awful UX. The type field should be first, and the button fields shouldn't even appear unless type is set to Key/Mouse Button.
I hate unity's input manager so much. It's the most painful part of starting a new project by far. In fact I think the unity framework should come with an XInput interface, and ideally a PlayStation equivalent, built in.
+1
MachwingIt looks like a harmless old computer, doesn't it?Left in this cave to rot ... or to flower!Registered Userregular
I'm really starting to get a bit of a groove on with my Pico 8 development.
Like bam, another game knocked out in a couple of hours - this one a knock-off of the low-to-high Braintraining game. Far, far better code than my previous effort.
I'm really starting to get a bit of a groove on with my Pico 8 development.
Like bam, another game knocked out in a couple of hours - this one a knock-off of the low-to-high Braintraining game. Far, far better code than my previous effort.
I'm really starting to get a bit of a groove on with my Pico 8 development.
Like bam, another game knocked out in a couple of hours - this one a knock-off of the low-to-high Braintraining game. Far, far better code than my previous effort.
I'm particularly happy with the card-turning-over-effect. Pico-8 works with 8x8 sprites, to allow proper centering of the numbers the cards are 9x9 - nightmare.
Has anyone used Qubicle? I'm considering it. My characters were built out of Unity primitives until this weekend when I started replacing them with rigged models.
But it's hard to maintain voxel-y proportions in Blender. I was just idly searching for voxel programs and the price on this one seems pretty reasonable.
The input manager in Unity could use some work. It's where you map inputs to axes, but look at this:
You might expect to be able to use wasd, the arrow keys, or the joystick's 6th axis.
Nope. The "Type" field, 3/4 of the way to the bottom, is set to Joystick Axis. So the keys don't work. It's not broken, but it is awful UX. The type field should be first, and the button fields shouldn't even appear unless type is set to Key/Mouse Button.
Runevision (long time unity3d forumer, now working on the input team) hasn't laid out a timeline, but even using the unfinished system is a huge upgrade. It handles multiple controllers beautifully, mappings are stored in serialized ScriptableObject assets, and you can separate them into multiple control schemes for different modes (e.g. vehicle, on foot, etc).
They've warned that it may change drastically by its official release, but I've found it entirely worth it to integrate now.
I hate unity's input manager so much. It's the most painful part of starting a new project by far. In fact I think the unity framework should come with an XInput interface, and ideally a PlayStation equivalent, built in.
Also, incidentally, I finished my polymorphic editor, and I've moved on to an input manager that I hope will work more like fighting games with batching input into discrete frames.
Does anyone know if something like that already exists for Unity? If not, is it something worth putting up on the store for cheap or free?
Reading the last few pages of this has me wanting to finish up my top down space combat game when I have some time.
Which may be soon as my contract job ends this Friday, though I may endup with a new job before the end of the week. We shall see...
Also tempted to rebuild it from the ground up for a second time because I can't make it network mp enabled due to some design decisions I made awhile ago. Plus I feel like I could achieve the same gameplay results with like half the code.
On the other hand I could finish what I have and release it as a SP only game faster. Decisions...
DarkMecha on
Steam Profile | My Art | NID: DarkMecha (SW-4787-9571-8977) | PSN: DarkMecha
Reading the last few pages of this has me wanting to finish up my top down space combat game when I have some time.
Which may be soon as my contract job ends this Friday, though I may endup with a new job before the end of the week. We shall see...
Also tempted to rebuild it from the ground up for a second time because I can't make it network mp enabled due to some design decisions I made awhile ago. Plus I feel like I could achieve the same gameplay results with like half the code.
On the other hand I could finish what I have and release it as a SP only game faster. Decisions...
I don't know how fast "faster" is, but if you're relatively close to a releasable game I'd say you should finish it and release it as a singleplayer only game. Then if you're still in love with the game after that, you can re-make it as Top Down Space Combat Game 2 now with more multiplayer and all the features you wanted to add before but had to cut.
Reading the last few pages of this has me wanting to finish up my top down space combat game when I have some time.
Which may be soon as my contract job ends this Friday, though I may endup with a new job before the end of the week. We shall see...
Also tempted to rebuild it from the ground up for a second time because I can't make it network mp enabled due to some design decisions I made awhile ago. Plus I feel like I could achieve the same gameplay results with like half the code.
On the other hand I could finish what I have and release it as a SP only game faster. Decisions...
I don't know how fast "faster" is, but if you're relatively close to a releasable game I'd say you should finish it and release it as a singleplayer only game. Then if you're still in love with the game after that, you can re-make it as Top Down Space Combat Game 2 now with more multiplayer and all the features you wanted to add before but had to cut.
Yeah, you are right. Basically I have a few more things to code, the player UI to build, and then just lots of art assets (the fun part!). Plus multiplayer for indie games seems to die off fast anyways.
Steam Profile | My Art | NID: DarkMecha (SW-4787-9571-8977) | PSN: DarkMecha
I've been following a strategy of adding features into the game before adding the content. The idea being that with the features done content creation will be easier.
The problem is that every time I complete something, another idea pops into my head. I will have to draw the line soon before Parbolus turns into a low budget version of Duke nukem.
So I never did CS, and therefore this is going to be a dumb question.
I have a bunch of unity objects that have scripts attached to them with the public void moveforwards() in them.
public void moveforwards()
{
transform.Rotate(Vecor3.forward,Playermover.rotatespeed * Time.deltaTime
}
Now I want to define these in one central script as 20 separate GameObjects. How do I apply the public void moveforwards() to each GameObject in turn?
Are you saying that you have 20 different script files with different names, and each game object has a unique script?
1) you can reuse scripts. Just drag your script out of the file browser window and drop it into an object's inspector.
2) what unity does is call each component's Update method automatically. Define a void Update() in the same script, and in Update call your MoveForward method.
3) this is less a CompSci question and more a question unique to unity. I did go to school for CS, and I still have to ask a bunch of questions about how it works. :-)
Man reading about networking in the Unity forums has me doubly deciding to just finish what I have as a singleplayer game. Apparently hiding latency even on simpler stuff can be hard. The way I have things setup now is all very physics based and accurate, which from what I'm reading might not translate well to internet multiplayer. Thankfully it all works quite well as a singleplayer game. I tested something like 250 AI ships battling it out and had no FPS lag at all! My comp has an i5, 16gb ram, and a 970 in it so part of that is the specs are way high for this kind of game but at the same time I only plan to maybe at most have like 50 ships in a given battle.
Steam Profile | My Art | NID: DarkMecha (SW-4787-9571-8977) | PSN: DarkMecha
Are you saying that you have 20 different script files with different names, and each game object has a unique script?
1) you can reuse scripts. Just drag your script out of the file browser window and drop it into an object's inspector.
2) what unity does is call each component's Update method automatically. Define a void Update() in the same script, and in Update call your MoveForward method.
3) this is less a CompSci question and more a question unique to unity. I did go to school for CS, and I still have to ask a bunch of questions about how it works. :-)
1 + 2 I have handled. I had the same script on 19 objects. Now, because I need to track their position, I want to move all their functions to a central script.
So what I want to do is something like
gameobject_1.MoveForward();
gameobject_2.MoveForward();
etc.
Now of course because this is a centralised script, complications. Because moveforward then has to go
Simply put, I need to be able to swap GameObject wherever mentioned in the function. Or do a trick that comes down to the same thing.
At the moment, my script contains the functions move_1 to move_19... And so do many of my other scripts, for many functions. It's really annoying to not be able to reuse functions; I really would like to know if there's a smarter way to do it.
Are you saying that you have 20 different script files with different names, and each game object has a unique script?
1) you can reuse scripts. Just drag your script out of the file browser window and drop it into an object's inspector.
2) what unity does is call each component's Update method automatically. Define a void Update() in the same script, and in Update call your MoveForward method.
3) this is less a CompSci question and more a question unique to unity. I did go to school for CS, and I still have to ask a bunch of questions about how it works. :-)
1 + 2 I have handled. I had the same script on 19 objects. Now, because I need to track their position, I want to move all their functions to a central script.
So what I want to do is something like
gameobject_1.MoveForward();
gameobject_2.MoveForward();
etc.
Now of course because this is a centralised script, complications. Because moveforward then has to go
Simply put, I need to be able to swap GameObject wherever mentioned in the function. Or do a trick that comes down to the same thing.
At the moment, my script contains the functions move_1 to move_19... And so do many of my other scripts, for many functions. It's really annoying to not be able to reuse functions; I really would like to know if there's a smarter way to do it.
Typically, you don't centralize things in an Object & Components system. Just by having the component on each object, it will take care of itself.
Could you talk a little more about why you want one script to be aware of all the objects?
Edit:
As an aside, until I know more about how you need to track your objects, I can speak to reusability in a general sense. One way is method parameterization. You define a method with parameters that could represent any arbitrary object. Then, when you call that method, you pass in a variable as an argument. Inside the method itself, the argument's value is in your parameter. You don't need to know which object it is!
For example:
public void OnTriggerEnter2D(Collider2D other)
{
if (reactor != null) { return; }
if (!Reactive) { return; }
reactor = other.GetComponent<Reactor>();
ReactContact();
}
@Cornucopiist I'm not sure exactly what you're trying to accomplish either but, if you already have a component on an object with the MoveForward function then you don't need to do:
So instead of storing references to the gameObjects themselves, it might make more sense to store references to each component. That being said, I think I agree with templewulf in that you probably don't want to centralize the call for MoveForward. Instead, maybe think of ways that the component itself can decide when it needs to MoveForward. If they're always moving forward, then you can put it in the Update function.
The design architecture you use for games, unity included, is very important.
If you find yourself using the same lines of code in multiple places, that's a good sign that you should put all that in one place. A separate script that you can attach to many objects which has that code in it will do.
Also, you probably don't want a function called moveForward() as you've written it. What you probably want instead is for the code in moveForward() to be in Update() so that it is called automatically every frame. Then, you tweak the rotatespeed variable (between 0 and maxRotateSpeed) to set how fast you'd like the rotation to be, dynamically.
This is a LOT less of a hassle than having each object have a separate script that has to be aware of every single component your object contains, so it can call methods from them piecemeal.
The design architecture you use for games, unity included, is very important.
If you find yourself using the same lines of code in multiple places, that's a good sign that you should put all that in one place. A separate script that you can attach to many objects which has that code in it will do.
Also, you probably don't want a function called moveForward() as you've written it. What you probably want instead is for the code in moveForward() to be in Update() so that it is called automatically every frame. Then, you tweak the rotatespeed variable (between 0 and maxRotateSpeed) to set how fast you'd like the rotation to be, dynamically.
This is a LOT less of a hassle than having each object have a separate script that has to be aware of every single component your object contains, so it can call methods from them piecemeal.
I usually prefer to have my methods organized into sort of "verbs", like MoveForward(). Hooks like Update() can call them, but generally I isolate things as much as possible.
It's probably largely due to my time in PHP with gross code that dumps everything into one file, then going into Ruby in which every variable, keyword, or method could secretly be some other method underneath it doing things that you didn't even know were side effects.
Posts
For some reason, I desperately want to play this in VR!
I've got an opportunity to have my own 10x10 corner for pretty cheap for an event coming up this summer and I am seriously considering taking up the offer for 2 days playtesting and promotion.
I would love to have a chat about your experiences if you've hosted one or been involved with one. Hit me up via PM. Thanks!
@HallowedFaith I haven't done one personally, but my business partner has shown off our game at a few local conventions. I could put you in touch?
Unreal Engine 4 Developers Community.
I'm working on a cute little video game! Here's a link for you.
I actually got a Vive specifically so I could test out doing it in VR, and I still want to maybe add that, but I had to have it finished by today and there were other, more important things, so I never got around to even testing out to see if it would work. I assume it would, I just need to enable it and try.
It's still on my post-release bucket list.
In other news, the game's live now!
Itch has the latest release, (it's still free!)
I've done a bunch of trade shows for software that is much more boring than games. And my biggest piece of advice is to come with a partner. First because setting up and paperwork and travel is boring but mainly so there is someone to watch your stuff while you go take a leak. And that way you can engage with more than one person/group at a time.
If you want your booth to look good you will need to get a bunch of stuff printed (before the day of because shit always goes wrong) and you will want to spend some money on some handouts with your branding on them.
You should go do it though, you can't really screw up. Worst case scenario is you was a bit of money and time but you will usually have a good experience.
I have had a booth at PAX before for InFlux. It was a big ol' success, but it would have been less so if I hadn't paid great heed to this Brendon Chung blog post on boothing. And absolutely have one or two other people helping out around the booth. Set up multiple machines so multiple people can play, etc.
My booth looked like this:
3 PCs where people could play a nearly-done build of the game on 360 controllers, and the TV is just looping the trailer. A hidden laptop is cranking the soundtrack through some massive old speakers so people walking by can hear (players have optional over-ear headphones). All 3 machines were pretty much in use the entire 3 days so I guess we could have used another. The table the PCs are on is an ugly one so the tablecloth was a must
I've got 3 playing stations planned w/headphones. Didn't even think about the soundtrack being played at the booth, that is smart! Appreciate that link, will totally give it a read.
Wait, is that how they did it? I never knew!
Middle mouse button summons help topic for any command you on, opens a script if you click on that, and if you happen to reference an object in code, it will again open that up. It is an immense timesaver that I learned about months too late
I would also encourage you to learn exactly what version of gamemaker you have at the moment so that you do not gallantly go charging off onto a project you can never complete.
http://www.fallout3nexus.com/downloads/file.php?id=16534
I made a game, it has penguins in it. It's pay what you like on Gumroad.
Currently Ebaying Nothing at all but I might do in the future.
You might expect to be able to use wasd, the arrow keys, or the joystick's 6th axis.
Nope. The "Type" field, 3/4 of the way to the bottom, is set to Joystick Axis. So the keys don't work. It's not broken, but it is awful UX. The type field should be first, and the button fields shouldn't even appear unless type is set to Key/Mouse Button.
Never used Python, then?
Or any language where you can define custom array bounds rather then being bound by the tyranny of 0 to arraylength - 1. Love Ada.
I made a game, it has penguins in it. It's pay what you like on Gumroad.
Currently Ebaying Nothing at all but I might do in the future.
Like bam, another game knocked out in a couple of hours - this one a knock-off of the low-to-high Braintraining game. Far, far better code than my previous effort.
http://www.lexaloffle.com/bbs/?tid=29326
I made a game, it has penguins in it. It's pay what you like on Gumroad.
Currently Ebaying Nothing at all but I might do in the future.
That's pretty dope!
I'm particularly happy with the card-turning-over-effect. Pico-8 works with 8x8 sprites, to allow proper centering of the numbers the cards are 9x9 - nightmare.
I made a game, it has penguins in it. It's pay what you like on Gumroad.
Currently Ebaying Nothing at all but I might do in the future.
But it's hard to maintain voxel-y proportions in Blender. I was just idly searching for voxel programs and the price on this one seems pretty reasonable.
The Unity New Input System is pretty great!
Runevision (long time unity3d forumer, now working on the input team) hasn't laid out a timeline, but even using the unfinished system is a huge upgrade. It handles multiple controllers beautifully, mappings are stored in serialized ScriptableObject assets, and you can separate them into multiple control schemes for different modes (e.g. vehicle, on foot, etc).
They've warned that it may change drastically by its official release, but I've found it entirely worth it to integrate now.
fukk yeah
Also, incidentally, I finished my polymorphic editor, and I've moved on to an input manager that I hope will work more like fighting games with batching input into discrete frames.
Does anyone know if something like that already exists for Unity? If not, is it something worth putting up on the store for cheap or free?
Which may be soon as my contract job ends this Friday, though I may endup with a new job before the end of the week. We shall see...
Also tempted to rebuild it from the ground up for a second time because I can't make it network mp enabled due to some design decisions I made awhile ago. Plus I feel like I could achieve the same gameplay results with like half the code.
On the other hand I could finish what I have and release it as a SP only game faster. Decisions...
I don't know how fast "faster" is, but if you're relatively close to a releasable game I'd say you should finish it and release it as a singleplayer only game. Then if you're still in love with the game after that, you can re-make it as Top Down Space Combat Game 2 now with more multiplayer and all the features you wanted to add before but had to cut.
Yeah, you are right. Basically I have a few more things to code, the player UI to build, and then just lots of art assets (the fun part!). Plus multiplayer for indie games seems to die off fast anyways.
The problem is that every time I complete something, another idea pops into my head. I will have to draw the line soon before Parbolus turns into a low budget version of Duke nukem.
I have a bunch of unity objects that have scripts attached to them with the public void moveforwards() in them.
public void moveforwards() { transform.Rotate(Vecor3.forward,Playermover.rotatespeed * Time.deltaTime }Now I want to define these in one central script as 20 separate GameObjects. How do I apply the public void moveforwards() to each GameObject in turn?Are you saying that you have 20 different script files with different names, and each game object has a unique script?
1) you can reuse scripts. Just drag your script out of the file browser window and drop it into an object's inspector.
2) what unity does is call each component's Update method automatically. Define a void Update() in the same script, and in Update call your MoveForward method.
3) this is less a CompSci question and more a question unique to unity. I did go to school for CS, and I still have to ask a bunch of questions about how it works. :-)
1 + 2 I have handled. I had the same script on 19 objects. Now, because I need to track their position, I want to move all their functions to a central script.
So what I want to do is something like
Now of course because this is a centralised script, complications. Because moveforward then has to go
for gameobject 1 and
for gameobject 2
Simply put, I need to be able to swap GameObject wherever mentioned in the function. Or do a trick that comes down to the same thing.
At the moment, my script contains the functions move_1 to move_19... And so do many of my other scripts, for many functions. It's really annoying to not be able to reuse functions; I really would like to know if there's a smarter way to do it.
Typically, you don't centralize things in an Object & Components system. Just by having the component on each object, it will take care of itself.
Could you talk a little more about why you want one script to be aware of all the objects?
Edit:
As an aside, until I know more about how you need to track your objects, I can speak to reusability in a general sense. One way is method parameterization. You define a method with parameters that could represent any arbitrary object. Then, when you call that method, you pass in a variable as an argument. Inside the method itself, the argument's value is in your parameter. You don't need to know which object it is!
For example:
public void OnTriggerEnter2D(Collider2D other) { if (reactor != null) { return; } if (!Reactive) { return; } reactor = other.GetComponent<Reactor>(); ReactContact(); }If you find yourself using the same lines of code in multiple places, that's a good sign that you should put all that in one place. A separate script that you can attach to many objects which has that code in it will do.
Also, you probably don't want a function called moveForward() as you've written it. What you probably want instead is for the code in moveForward() to be in Update() so that it is called automatically every frame. Then, you tweak the rotatespeed variable (between 0 and maxRotateSpeed) to set how fast you'd like the rotation to be, dynamically.
This is a LOT less of a hassle than having each object have a separate script that has to be aware of every single component your object contains, so it can call methods from them piecemeal.
I usually prefer to have my methods organized into sort of "verbs", like MoveForward(). Hooks like Update() can call them, but generally I isolate things as much as possible.
It's probably largely due to my time in PHP with gross code that dumps everything into one file, then going into Ruby in which every variable, keyword, or method could secretly be some other method underneath it doing things that you didn't even know were side effects.