I am not quite sure I properly understand your question, you want to replace for, while and foreach loops with recursion - i.e. a function calling itself? Because without that I do not see a way to replace a loop (that does not have the number of calls hard coded) by function calls. So in case you do mean replacing loops by recursion: Recursion comes with a certain overhead for the stack, because whenever you call a function, the runtime environment needs to remember "where you came from". This means that recursion is a bit slower (though that usually is not too important) and is limited in terms of how many iterations you can compute, because of the limited stack size. Recursion often yields elegant solutions, that are very compact though, so it is not all bad. Usually, it is a good practice to come up with a recursive solution and then to build a more efficient iterative solution based on that.Hello, this time i'm here because I want to know why using Loop (for,while,foreach) when You can use the invoke repeating method/function?
I want to know the pro and cons of Loop and Invoke repeating method/function, and thank you for taking your time to reply :)
I'm using UnityEngine and Csharp.
P.s I think I'm almost done with my first ever game :D
I'm trying to understand the difference between loops and invokerepeat, I have no idea about this recursion function.I am not quite sure I properly understand your question, you want to replace for, while and foreach loops with recursion - i.e. a function calling itself? Because without that I do not see a way to replace a loop (that does not have the number of calls hard coded) by function calls. So in case you do mean replacing loops by recursion: Recursion comes with a certain overhead for the stack, because whenever you call a function, the runtime environment needs to remember "where you came from". This means that recursion is a bit slower (though that usually is not too important) and is limited in terms of how many iterations you can compute, because of the limited stack size. Recursion often yields elegant solutions, that are very compact though, so it is not all bad. Usually, it is a good practice to come up with a recursive solution and then to build a more efficient iterative solution based on that.
A loop will determine the value you need in the same frame / update function, invokerepeat (sorry, I did not get you were talking about this Unity specific construct) will call a method at a fixed time interval, repeatedly. They both have vastly different use cases. If you want to sum up elements in an array, you will not use invokerepeat. If you want to define continued behaviour over an extended period of time, then a loop does not make sense, because it will all execute within the same frame. Use a while-loop to move forward a projectile and you end up with a projectile being in its destination point within the same frame, which is hardly usable in a game.I'm trying to understand the difference between loops and invokerepeat, I have no idea about this recursion function.
Is recursion the same function as invoke?
Thanks for the explaination :DA loop will determine the value you need in the same frame / update function, invokerepeat (sorry, I did not get you were talking about this Unity specific construct) will call a method at a fixed time interval, repeatedly. They both have vastly different use cases. If you want to sum up elements in an array, you will not use invokerepeat. If you want to define continued behaviour over an extended period of time, then a loop does not make sense, because it will all execute within the same frame. Use a while-loop to move forward a projectile and you end up with a projectile being in its destination point within the same frame, which is hardly usable in a game.
uh... https://www.humblebundle.com/software/rpg-maker-returns-softwareI'm surprised there haven't been any RPG Maker sales in a while.
They used to have those bundles every few months, I think.
Still debating whether to make my game into an old-school visual novel or more like the Corpse Party games.
I have got a small issue with Unity's shadow system. The shadow distance only takes x- and z-axis into account, but not y-axis. This is pretty annoying, because I have used positioning for special areas that that one can teleport to (via "doors"), and now if an area is 2000 above another area, the shadows from the upper area still affect the lower area. This of course also has the side effect of causing additional meshes to be computed, but "luckily", I did not notice the shadow issue before today and optimised everything under the assumption that these objects are automatically culled by camera (so performance is not affected).
I could solve this via a script that disables the renderer manually, of course, but before I do that I wanted to ask if someone knows a more elegant / in-built solution to limit from how far above shadows can be generated.
I'm trying to concept out how to do the pause effect for super moves (example)
I already have a pause effect that I'm reusing for hitstop that basically just deactivates everything except itself, screenshots the screen for x seconds until a timer countsdown, and then reactivates everything. But that won't work for this since I want to pile on visual FX and so on during the super activation time.
Was thinking of... some kind of state in the state machine for every character where it pauses on the current frame of animation, stores all current movement information (to retain physics when it reactivates), sets hspd/vspd to 0 and deactivates gravity/friction, exists in that for x seconds, then dumps all the movement info back in the proper vars when the timer expires?
Does that make sense?
Would also be able to add a shaking effect on hits which would also be nice, if this is reusable.
Thank you for the link, it is indeed interesting, but I cannot use that, because I am on an older Unity version (developing for Wii U), older than the dynamic rendering pipe line feature in Unity.I don't have much experience in this area but I can point in a possible direction not sure how much it'll help. The first thing that came into my mind was the Scriptable Render Pipeline. My knowledge on SRP is basically this video. Here's a couple of things i found not sure how much help they'll be, 1, 2. If you're not already you'll need to probably switch to the LWRP or HDRP. Should be explained in the first video. Let me know how it goes!
Edit: 2 - Newer article.
Sure, but what's your practice for that - do you flip the object to a separate state that is the 'hitstop' state while retaining all the current vars, or is there some kind of step code override so you can do it in whatever state you're already in?
maybe it is just an 'if (hitstop) [do hitstop stuff; exit]' in the step event... hmmm
IEnumerator HitStopCoroutine (bool isAttacker, float duration) {
EntityStateEnum hitStopState = isAttacker
? EntityStateEnum.AttackerHitStop
: EntityStateEnum.DefenderHitStop;
yield return new WaitForEndOfFrame ();
if (!GetState ().IsState (hitStopState)) {
// Set hit stop state.
SetState (hitStopState, true);
bool grounded = IsGrounded ();
Vector2 oldVelocity = Vector2.zero;
if (_rigidbody != null) {
// Store velocity to be able to restore it later.
oldVelocity = GetVelocity ();
Vector2 newVelocity = oldVelocity;
// Freeze the rigidbody horizontally.
newVelocity.x = 0f;
if (!grounded) {
// In midair: also freeze vertically.
newVelocity.y = 0f;
// In midair: remove gravity.
_rigidbody.isKinematic = true;
}
// Apply frozen velocity.
SetVelocity (newVelocity);
}
// Stop animation (important especially if it's
// the attacker).
_animator.speed = 0f;
if (_animationController != null) {
_animationController.PushPause ();
}
// If this is the target, and it's not attached, vibrate.
// Otherwise just freeze for the duration.
if (!isAttacker && !GetState ().IsState (EntityStateEnum.Clung)) {
yield return VibrateCoroutine (
duration,
DamageConstants.HitStopVibrationMaxDistance,
DamageConstants.HitStopVibrationPeriod);
}
else {
yield return new WaitForSeconds (duration);
}
// Remove hit stop state.
SetState (hitStopState, false);
// Restore animator speed.
_animator.speed = GetSpeedFactor ();
// Restore normal physics.
RecalculatePhysics ();
// Restore original velocity.
if (grounded) {
// Grounded: don't actually restore old vertical
// speed (preserve the current speed).
oldVelocity.y = GetVelocity ().y;
}
SetVelocity (oldVelocity);
// Resume ongoing animation (particularly important
// if this is the attacker).
if (_animationController != null) {
_animationController.PopPause ();
}
}
}
I had the concept of the game (Flying around with a Jetpack, trying not to crash into things) and I knew I wanted a title that was either a little bit funny or a little bit cute, and I also knew I wanted to have a title before properly got started. I felt that the titles of "Safety not guaranteed" (film) and "No Time to Explain" (game)were pretty good as they conveyed the tone of the media purely through the title, and I wanted to replicate that for my own game.
I wanted people to know that the game was light-hearted, a little bit silly and preferably quite memorable. As far as I can remember, I didn't actually have many other ideas as I came to it fairly quickly after that and I had a kind-of "Yep, that's the one" moment. It also helped me work on a little elevator-pitch with the title being used almost like a punchline:
It's a 2D precision-action game where you play as a test-pilot for a prototype jet-pack, flying through a futuristic city whilst trying not to crash into buildings, traffic and pretty much everything else in your way. It's called "Please Wear a Helmet"!
I tried that out on a couple of people around the studio where I was working at the time and it made them chuckle, so I felt like it was a pretty good choice!
I wasn't really able to settle on the name until I had decided my setting and a very loose plot/narrative. Maybe once you've done that it'll give you more to work on? Of course, the name may just come to you at some point when you least expect it. What is your game going to be about?
Looking cool. I can play test it for a bit if that's what you're looking for.I'm a little late for screenshot saturday, but still working on that gothic retro shooter :D Pretty close to getting it feature-complete so I can start working on maps, enemies, and bosses. Would it be ok to ask about playtesting in this thread?
I have got a small issue with Unity's shadow system. The shadow distance only takes x- and z-axis into account, but not y-axis. This is pretty annoying, because I have used positioning for special areas that that one can teleport to (via "doors"), and now if an area is 2000 above another area, the shadows from the upper area still affect the lower area. This of course also has the side effect of causing additional meshes to be computed, but "luckily", I did not notice the shadow issue before today and optimised everything under the assumption that these objects are automatically culled by camera (so performance is not affected).
I could solve this via a script that disables the renderer manually, of course, but before I do that I wanted to ask if someone knows a more elegant / in-built solution to limit from how far above shadows can be generated.
EDIT: While I would still be interested in a more elegant solution in principle, I have now solved the issue by programming a script that turns renderers or shadows (depending on the level element) off based on the user position.
In this particular instance, yes, just fully disabling the other areas is not possible, because there is some synchronisation going on. It is a level with three copies of the same level in different sizes, where some puzzles require synchronisation. The synchronisation could be solved another way, of course, but completely changing how the puzzle is programmed would not be a good idea at this stage anymore. Disabling renderers (and on the very few objects where they need to remain active, the shadow functionality) has worked fine though. I still do not understand what the benefit is in allowing shadows from arbitrary height, it's neither natural, nor practical.I'm not sure I've got the whole picture, but is having those special areas enabled when they're off screen important at all? Are there side effects in your scripts to disabling them? It sounds like ideal behavior could be just turning them on when the player teleports to them, rather than messing around with the notoriously hard-coded shadow system. If you get unwanted behavior from disabling objects, just disabling renderers does seem like the way to go.
In this particular instance, yes, just fully disabling the other areas is not possible, because there is some synchronisation going on. It is a level with three copies of the same level in different sizes, where some puzzles require synchronisation. The synchronisation could be solved another way, of course, but completely changing how the puzzle is programmed would not be a good idea at this stage anymore. Disabling renderers (and on the very few objects where they need to remain active, the shadow functionality) has worked fine though. I still do not understand what the benefit is in allowing shadows from arbitrary height, it's neither natural, nor practical.
Can you stagger them horizontally instead of vertically?In this particular instance, yes, just fully disabling the other areas is not possible, because there is some synchronisation going on. It is a level with three copies of the same level in different sizes, where some puzzles require synchronisation. The synchronisation could be solved another way, of course, but completely changing how the puzzle is programmed would not be a good idea at this stage anymore. Disabling renderers (and on the very few objects where they need to remain active, the shadow functionality) has worked fine though. I still do not understand what the benefit is in allowing shadows from arbitrary height, it's neither natural, nor practical.
Yes, that would have been an option as well, but it is limited to at most nine, rather than up to 27 areas - and I have another level where that would not be sufficient - and also, in this specific case, the areas are built in two ways: One part is automated cloning, and another is that some objects specific to the respective area. So I would have to compute new coordinates for all the objects that placed manually (grouping of course helps) and I would lose a lot of testing progress. The solution I have now used is probably more practical, because it is only a minor change from in programming and actually no change at all in scene set-up. The timing until 3rd of November is tight, so this is also a relevant consideration.
UnityEngine.SceneManagement.SceneManager.LoadScene(<name of scene>);Hello, I'm here because I want to have a button for the mainscreen to load the first level, but I don't know where to search, everything I found is just obsolete functions that have been updated and I don't know where to find the updated functions, for example the Application.LoadLevel(string) is obsolete :(
Cool, thanksUnityEngine.SceneManagement.SceneManager.LoadScene(<name of scene>);
Cool, thanks
and can you give me the link where to find updated stuff?
Thanks, I'm using Unity 2019.Googling the function game me this:
This is the latest version of the documentation, although you can select previous versions (in case you're using, say, Unity 2018 like I am) with the top left dropdown.
Try thisThanks, I'm using Unity 2019.
How can I make a button call the scene?
like "click here to start a new game" and when I click the button it will load the first scene (level01), I want to know how I can implement SceneManagement with a Button UI.
There's OnClick() but I don't know how it works.
I will, thanks
KV331 Audio is giving away SynthMaster Player for free from now until October 31.
....
BTW, being a VSTi, this isn't a standalone program and does requires a DAW to use. If you don't have one, check out Reaper or Tracktion T7.
Thanks for that. I've only dabbled in music creation for my games so far but soon I'm going to have to start learning and experimenting with it soon.
Anyone know a good free DAW which allows PC keyboard control? I don't own a MIDI keyboard, nor do I want to spend the money on one for my "hobby" game development. :)
I don't know if other free DAWs out there have virtual MIDI keyboard functionality, which is why I listed Reaper and Tracktion T7. =)
While Reaper isn't free to own, it is free to try, and does come with that function built in.
Tracktion T7, which is 100% completely free, has this as well. Both require some set up on your part.
Here are YouTube videos for both of these in action:
Here's a link to other free DAWs for various operating systems via the Bedroom Producers blog. Good luck!
KV331 Audio is giving away SynthMaster Player for free from now until October 31.
Compared to their other instruments, SynthMaster Player focuses on those who'd rather use presets instead of designing their own sounds. If you're someone that regularly makes their own ensembles in Reaktor and disdains presets, this might not be for you. While there are some parameters you can edit, nothing is exposed as it would be in a typical synthesizer.
This is the regular $29 version of SynthMaster Player that comes with 1800 factory presets instead of the 550 of the "SynthMaster Player FREE" version. This also gives you the option to upgrade to SynthMaster and/or SynthMaster One at a discount if you want to. I feel that many of the included sounds (that I've tried so far) are good and usable, but YMMV of course.
Posting this here as SynthMaster Player comes with quite an assortment of sound effects as well as arpeggios/sequences that can possibly be used somewhere in your game production. It's something I leaned on for years back when doing game dev. Find something useful, adjust some parameters, export it, and move on to the next task on your list.
BTW, being a VSTi, this isn't a standalone program and does requires a DAW to use. If you don't have one, check out Reaper or Tracktion T7.
Sure, but what's your practice for that - do you flip the object to a separate state that is the 'hitstop' state while retaining all the current vars, or is there some kind of step code override so you can do it in whatever state you're already in?
maybe it is just an 'if (hitstop) [do hitstop stuff; exit]' in the step event... hmmm