If you want to have different powerups we can create an enum outside the PowerUp class. For example: public enum PowerUpsAvailable { Grow, HealthBoost } Then we can add an object in the class. public PowerUpsAvailable powerUpType; And in the Inspector window we shall see the combo box with the Grow and Health Boost elements. And then you can add this to your Pickup function: switch (powerUpType) { case PowerUpsAvailable.Grow: //Do something break; //We don't want errors! case PowerUpsAvailable.HealthBoost: //Do something else break; default: Debug.Log("The type is invalid"); break; }
How would you assign a specific power up to an outcome? Say I wanted one power up to give me health, and another to give me speed, how would I do that?
If the player is not interacting with the power-up in 2D when touching it try "void OnTriggerEnter2D (Collider2D other)" instead of "void OnTriggerEnter (Collider other) ".
For people just here for the timer: Make a function with return type IEnumerator. Put what you want to happen for a certain amount of time in the function. Below it, type "yield return new WaitForSeconds(seconds);" without the quotes. Write the after timer code below it. When calling the function, do: "StartCoroutine(Function());" without the quotes.
Crysis was the very first game to use Ambient Occlusion. It is now a part of almost every physically based rendering engine! It's amazing. Such a simple technique, yet so effective.
A message to all future game devs: Don't give up even though it may look very hard and you think that youre maybe not smart enough or you arent cut out for this, just keep watching these kinds of tutorials but instead of just copying the code, try to understand how it works and how you can change it to do various things be creative.
For anyone who also has a problem with looping of effect. When you download Unity Particle Pack and put some random effect to the script, this effect starts again and again after triggering. You can fix it by doing next actions: 1. Click on the effect in the bottom assets panel. 2. In the Inspector on the right side find the "Looping" option inside the Particle System component and disable this option. 3 (Optional). If you still have looping effect, double click on effect in the bottom Assets panel and then you can see all children of this effect inside the hierarchy on the right. Just repeat step 2 for each child.
Love all of your videos, they've been extremely informative and have helped me really start getting into using Unity. In this video though there is one small issue that I see and that's that when you divide the player's health by the multiplier after the powerup runs out, if the player lost any HP, that loss will be reflected in the division of the HP stat(i.e: if the player gets the powerup and loses 50 HP, setting their HP to 90. Once the powerup fades, their HP will drop to 64). I'd recommend instead of dividing the multiplier you write an if statement like: if (stats.health > 100) {stats.health = 100;} and don't modify the HP at all if it's lower than 100 after powerup fades. Keep up the great work! Your tutorials are an excellent resource and I look forward to binge watching them as I develop my games ^_^
Another great tutorial, and the first tutorial where I knew enough where I could easily customize the script, I'm learning! I found that the prefab particle system wouldn't go away in the hierarchy after the powerup was destroyed so I added a destroy for the particle system to the script, but you can't destroy prefabs so I added a child particle system to the powerup object, but that one played on awake as soon as the scene opened in play mode, so I set it inactive and added a 'set active' in the code and a 'destroy after 2 seconds' behind that. Now that works all cleanly. And I also added a maxHealth so that the multiplier does both health and maxhealth, but when reverting them after the set duration it sets the health to the (max)maxhealth if it is greater than that, this should prevent a damaged player from reverting below the max health after the powerup health goes away.
Or even better the IEnumerator coroutine can stay on the player script and the powerup can destroy itself safely without worrying about stopping the time out effect. It's also closer to how we perceive powerups to actually work in games: the powerup passes the buff to the player. Anyways, amazing quality as always! :D
Hi Brackeys! Since BALL WARS is already touching the subject, I figured I'd ask for a video or two on local splitscreen? There's very few resources out there and a lot og subjects to wrap your head around. • Having several players but only 1 player tag? • 2-4 controllers active at the same time • Dynamic screensize/camera changes, depending on amount of players • And much more... Thank you for your videos :)
Managed to figure this out. Doing a Space Shooter and originally I wanted to do a Double Shot Powerup where the bolts fired spawn 2 of them instead of one. Instead I made it do Rapid Fire for 10 seconds instead. Its still progress. Thanks again for this tutorial.
Hey there, so... I also tried working on a space shooter following this tutorial and I can't, for the love of god, manage to get the collider to react to the onTriggerEnter2d. Powerup collider is a trigger, ship has a polygon collider which is not a trigger. Nothing happens when they touch and I have the same code as brackeys (but with 2D after OnTriggerEnter and Collider(2D).other. Any help, please?
Absolutely awesome! Simple instructions and even has a bit more advanced coding in there to help keep you progressing in your game development! So cool!
Yep. Its a shame he and the team left to do other things, but this man was literally the only way i couldve started making games. Good luck to you and your projects pal
As a CS student who just studied function prototyping, invoking, parameters and signatures on C++ this video is PERFECTLY timed! Also yeah, I study C++ and C# at the same time :D
This is a great starting point for a power up system... However, in a larger game, one may consider pulling the Player Stats out into its own singleton class, but that gets quite advanced very quickly.
Love your videos, they have helped me come so far as a programmer and game designer. I'm not sure if you take suggestions for videos, but i would love to see a tutorial which covers water/shaders/ripple&splash effects/swimming. The character could walk through the water and leave little ripples as they walk/ then a swimming & diving mechanic for when the water is deep enough. Keep up the great work!
You can do it, but Invoke is very limited in comparison to Coroutine. So is better to undestand and use Coroutine bacause tomorrow you will use it all the time :)
absolutely beautiful! in my mobile game I also have power ups but the effects you put on yours really opened my mind man thank you! would love any thought on my indie mobile survival game if anyone has free time!
for those who are getting this error Library\PackageCache\com.unity.postprocessing@2.0.3-preview\PostProcessing\Runtime\PostProcessManager.cs(424,66): error CS0117: 'EditorSceneManager' does not contain a definition for 'IsGameObjectInScene' update the package manager by going in Package Manager -> "In Project" and in that select Post Processing and then update it to the latest version
so 100hp * 1.4 = 140 / 1.4 = 100 Great, but what if you take damage?!?!? Lets say you get your health up to 140 and than you take 40 damage and after the power up expires you end up with 71hp instead of 100. Is there a better way to do that?!
you would need to use a maximum health as well. after the duration reduce the max health back and if current health is > than max reduce current to max
before make changes on health, make a variable in the coroutine float healthbeforechanges = health; after you can modify like *1.4 after the effect is done, just change current health with the variable healthbeforechanges
The health is only multiplied once so it would only be multiplied by 1.4 when you touch the power up, when you take damage it isn’t touch a power up so you don’t multiply
@@ДенисМаксименко-м9ц you could just store the difference in HP between the unmodified value and the value after multiplying it. and after the duration subtract the diff if it doesnt kill you/go lower than a fixed min value
This tutorial helped me a lot. But the Particle pack did not go over well with my project, right after importing my project was unusable. So without the particle pack great tutorial :D
Your videos are amazing! If I had any money, I would donate to your Patreon. Thanks for inspiring me to learn more about game design, I was about to give up on trying to develop games before I found your channel!
You could also control the power ups in a PowerUpScript inside the player. It would have a function that receives from the power up object the information about the variable to change, the amount and the duration and the PowerUpScript will take care of applying and controlling the duration. This way you can destroy the power up gameobject instantly.
I think it would be fun to have the power-up collider be a little larger than the pickup and on enter pull the power-up towards the player. Obviously it just depends what you're going for, but thought I'd share.
Although the quality of the videos and the way he teaches/explains is superb I'm finding many of the latest videos too simple. Having simple stuff is good because it gets people started but some more complicated stuff every so often would be nice.
Problem is, advanced coding in unity usually means you are coding for a more unique task. This content is something everyone can use. He does have cool things like post processing and shader graph.
Good work! love your videos and tutorials but I have a request from you and that is can you please make a tutorial about IEmurator and Corutine so we all can understand what it is and how can we use it. I have been suffering a lot to understand this particular subject. it will be awesome if you do that thanks for the great videos and keep up the great work 👌
Coroutines are actually pretty simple once you understand them. Each coroutine has 3 basic parts: 1. Defining the coroutine. Do this like you would any other function. Just be sure to have the return type be an IEnumerator (it's what makes it a coroutine). Example: public IEnumerator myCoroutine(). 2. Return an IEnumerator. All you need to do is return how long you want to coroutine to wait. The only special thing about it is that you have to write yield in front of it. Example: yield return new WaitForFixedUpdate(); There are multiple options for how long you want to wait. 3. Starting/stopping a coroutine. When you want to to start a coroutine write StartCoroutine(coroutine). When you want to stop a coroutine while it's running write StopCoroutine(coroutine) (you may want to do this when the game is paused for example). Example: StartCoroutine(myCoroutine()); StopCoroutine(myCoroutine()); So a typical coroutine might look like this: public IEnumerator myCoroutine(){ //some code yield return new WaitForFixedUpdate(); //some code } Here's how it works: When you start a coroutine it will act like any other function and start executing the code inside. Once it reaches a yield return statement, it will wait for however long you specified (seconds, end of frame, fixed update, etc.) and then it will continue executing the code after that yield return statement. Of course you can take advantage of this. If you put a while loop inside the coroutine, and have a yield return at the end of the loop, then the coroutine will wait for however long you specified before continuing. This effectually lets you control how often the while loop runs. You can also have more that 1 yield return statement if you want. Actual example: public IEnumerator boundCheck(){ while (Mathf.Abs(transform.position.x) < xLimit) { //&& same thing for y yield return new WaitForSeconds(0.5); } Destroy(gameObject); } This coroutine will destroy an object once out of bounds. First I'll start the coroutine (probably in Start() for this one). Then in the while loop condition I check whether I'm within the bounds for the x-axis (xLimit being the boundary). If I'm within that boundary, then my coroutine will wait for 0.5 seconds. After waiting the coroutine will continue on from that line. Since it was inside the while loop, the condition of the while loop will be checked again. If it's still within that boundary, it will wait another 0.5 seconds. If it's outside the boundary the condition of the while loop is false, so the code moves on to where it Destroys the gameObject the script is attached to.
I'm pretty sure you can run the power up reverse functions in a different thread so you can instantly destroy the game object when it is picked up and avoid disabling its components which I don't think is good practice.
Just a curiosity: Why can the PowerUp GameObject not be destroyed immediately? Since the effect has... taken effect, shouldn't the GameObject be moot at this point? Thanks!
1) Generate a random X and Z, set Y very high 2) Raycast downwards. 3) Get the Raycast Hit, it will contain a point from which you can extract Y 4) Instantiate at X, Y, Z
You're welcome. Also note that there are a lot of ways to handle this. For example if you generate the terrain from a heightmap, you could read the elevation coordinates and completely discard the Raycast computation, and so on... Depends heavily on what you already got on your game.
If you in 2D public class PowerUp : MonoBehaviour { void OnTriggerEnter2D (Collider2D other) { if (other.CompareTag("Player")) { Pickup(); } } void Pickup() { Debug.Log("Power up Picked up"); } }
Hi Brackeys! I love your videos and this is a great one for the class I'm currently in. I have one question though. when I types out "PlayerStats stats" stats is greyed out and in stats.speed I am getting red lines. speed is in our player stats script I was wondering what I could do to fix this
The problem with the reversion of the power up here is that it's proportional to the /current/ health rather than the amount gained at the time of taking the power up. That could be intentional, but wouldn't it be better to store the amount of health gained by the power up in a variable then subtract the player's health by that number once the duration ends?
When removing the effect can't i just make a new function called normal and reverse the effect in it And in the pickup method i just add invoke and the amout of seconds i want ?
Always subliminal with the tutorials man. I have a request though. I am working on 2D game in unity. Sample code below! The problem is that sometimes the delay time in the Invoke method gets skipped. The inconsistencies in the Invoke line of code is bugging. Please help. Sample code below! Thanks. public GameObject[] points = new GameObject[6]; void Update(){ if(Input.GetKey(KeyCode.A)){ PointPlay(points); } } void DelayMethod(){ } void PointPlay(GameObject[] theArray){ int start_x = 1f; int start_y = 1f; for(int i = 0; i < theArray){ theArray[i].transform.position = new Vector3(start_x, start_y, 0f); start_x += 2f; start_y += 2f; } Invoke("DelayMethod", 2.5f); }
This is nice, but a little simple. Personally, I would handle the effects in the player class, and have an enum in the power up class that defines buff types. The power up would pass the enum value as an int, along with the multiplier into a coroutine on the player. Keep up the good work, but maybe elaborate a bit more next time, because I can see people taking this the wrong way, and having a separate class for each power up, encouraging bad habits and increasing compile times. Thanks!
Can you make a video about Unity animator and its functions? I mean stuff such interpole between animation, animation blenders and whatnot. There seems to be a lack of tutorial on this matter in RUclips. So, I hope you can cover them in depth. Awesome video as always! xD
Hey brackeys love your videos and i love the insight that you give I hope you can make make a video about setting an instance it a very common error that arrises atleast for me. For example i would be writing a script for rounds and in another script i want to go to the function inside the rounds script and set a new round with a function but when i do it the way i usually do it it gives me an instance error.
Can I asked question?, ahm how can fix my multiplayer game because only one player can si the power-up I mean the effect of power but the other player can't see the first player power-ups and also this player can't see the object destroy after it pick-up? can you help me?
You wouldn't have to deal with the Mesh & Collider enabling if you handled the collision on the player instead of the powerup. It's also most logical, since only a player can affect a powerup and no other world object.
Great Tutorial! Just a quick note, you shouldnt be using a multiplier for something like health... if you have 140 health with the power up and lose 40 health during the effect.. you will end up with 100 and that gets divided by 1.4 the so you end up with much less health... you should compare if your hralth is higher than 100, then set it to 100. Else just leave it as it is :) thats how in my opinion is how its supposed to be in Games. Ofc that has nothing really to do with the tutorial, was just a quick note for game design ^^
I did, ive just come back to the issue after, like 3 hours. what you said is right, just maybe replace 100 with the max health variable for toggleability
First comes step 1, then step 3, then step 2.
GENIUS!!!
The commends above are spam bots. I meet comments like this everyday
If you want to have different powerups we can create an enum outside the PowerUp class. For example:
public enum PowerUpsAvailable
{
Grow,
HealthBoost
}
Then we can add an object in the class.
public PowerUpsAvailable powerUpType;
And in the Inspector window we shall see the combo box with the Grow and Health Boost elements.
And then you can add this to your Pickup function:
switch (powerUpType)
{
case PowerUpsAvailable.Grow:
//Do something
break; //We don't want errors!
case PowerUpsAvailable.HealthBoost:
//Do something else
break;
default:
Debug.Log("The type is invalid");
break;
}
How would you assign a specific power up to an outcome? Say I wanted one power up to give me health, and another to give me speed, how would I do that?
@@dragami1607 Assign different scripts to different powerups based on what you want to alter.
This is a good method, but it would use scriptable objects
I downloaded it a few days ago and I was struggling to find a good tutorial. Thanks for making an awesome tutorial as usual!
P000009090000099990099099 9 9000099090 0 99990p0009 9 990p000 00 9 0 009000 poopoop00999999 0090o 990p000 90p9 p9900000 0 00 9 90 90p9 0 9p 0 90pop99th0099 9 990p000
pop 9 9 90999099909999 o 90p9 9999999999999
@@__u.nknow.n___yb4149 what
Ey big smoke, wanna eat some number nines?
@@ananttiwari1337 just kids being kids
If the player is not interacting with the power-up in 2D when touching it try "void OnTriggerEnter2D (Collider2D other)" instead of "void OnTriggerEnter (Collider other)
".
THANK YOU
This helped me so much thank you!
love you
@zssllayers1946 Probably something to do with the z axis not really existing in 2D and everything appearing to have the same z position.
actually love u
So helpful!!! I'm a first year programmer/game dev at Uni and this was really easy to follow.
Your tutorials are very professional, they only get better :D
For people just here for the timer:
Make a function with return type IEnumerator.
Put what you want to happen for a certain amount of time in the function.
Below it, type "yield return new WaitForSeconds(seconds);" without the quotes.
Write the after timer code below it.
When calling the function, do: "StartCoroutine(Function());" without the quotes.
steps to build games :
step 1 : make stuff
step 3 : add effects
step 2 : make stuff do stuff
Forgot 1
4. Allow the player to do stuff
AA Porras forgot another, 5: rage quit and realise that games are very hard to make
Step 4: Go visit Brackeys channel to see what you did wrong.
step 9: add grappling guns
Step 11: regequit when brackets has no errors
Crysis was the very first game to use Ambient Occlusion. It is now a part of almost every physically based rendering engine!
It's amazing. Such a simple technique, yet so effective.
This is so clearly explained, I love it!
you saved my life, I hope you the best and I hope you continue doing videos like this too
A message to all future game devs:
Don't give up even though it may look very hard and you think that youre maybe not smart enough or you arent cut out for this, just keep watching these kinds of tutorials but instead of just copying the code, try to understand how it works and how you can change it to do various things be creative.
thanks for this comment!.
😓😓😭
For anyone who also has a problem with looping of effect.
When you download Unity Particle Pack and put some random effect to the script, this effect starts again and again after triggering. You can fix it by doing next actions:
1. Click on the effect in the bottom assets panel.
2. In the Inspector on the right side find the "Looping" option inside the Particle System component and disable this option.
3 (Optional). If you still have looping effect, double click on effect in the bottom Assets panel and then you can see all children of this effect inside the hierarchy on the right. Just repeat step 2 for each child.
I’m having problems picking up the power ups
Wow bro you're a life saver
Thank u dude
thank you brackeys you are a life saver, and im still so sad to see you go
Your videos are packed full of wholesome goodness.
Love all of your videos, they've been extremely informative and have helped me really start getting into using Unity.
In this video though there is one small issue that I see and that's that when you divide the player's health by the multiplier after the powerup runs out, if the player lost any HP, that loss will be reflected in the division of the HP stat(i.e: if the player gets the powerup and loses 50 HP, setting their HP to 90. Once the powerup fades, their HP will drop to 64). I'd recommend instead of dividing the multiplier you write an if statement like:
if (stats.health > 100) {stats.health = 100;}
and don't modify the HP at all if it's lower than 100 after powerup fades.
Keep up the great work! Your tutorials are an excellent resource and I look forward to binge watching them as I develop my games ^_^
Another great tutorial, and the first tutorial where I knew enough where I could easily customize the script, I'm learning!
I found that the prefab particle system wouldn't go away in the hierarchy after the powerup was destroyed so I added a destroy for the particle system to the script, but you can't destroy prefabs so I added a child particle system to the powerup object, but that one played on awake as soon as the scene opened in play mode, so I set it inactive and added a 'set active' in the code and a 'destroy after 2 seconds' behind that. Now that works all cleanly.
And I also added a maxHealth so that the multiplier does both health and maxhealth, but when reverting them after the set duration it sets the health to the (max)maxhealth if it is greater than that, this should prevent a damaged player from reverting below the max health after the powerup health goes away.
Or even better the IEnumerator coroutine can stay on the player script and the powerup can destroy itself safely without worrying about stopping the time out effect.
It's also closer to how we perceive powerups to actually work in games: the powerup passes the buff to the player.
Anyways, amazing quality as always! :D
Hi Brackeys!
Since BALL WARS is already touching the subject, I figured I'd ask for a video or two on local splitscreen? There's very few resources out there and a lot og subjects to wrap your head around.
• Having several players but only 1 player tag?
• 2-4 controllers active at the same time
• Dynamic screensize/camera changes, depending on amount of players
• And much more...
Thank you for your videos :)
Managed to figure this out. Doing a Space Shooter and originally I wanted to do a Double Shot Powerup where the bolts fired spawn 2 of them instead of one. Instead I made it do Rapid Fire for 10 seconds instead. Its still progress.
Thanks again for this tutorial.
Hey there, so... I also tried working on a space shooter following this tutorial and I can't, for the love of god, manage to get the collider to react to the onTriggerEnter2d. Powerup collider is a trigger, ship has a polygon collider which is not a trigger. Nothing happens when they touch and I have the same code as brackeys (but with 2D after OnTriggerEnter and Collider(2D).other.
Any help, please?
Absolutely awesome! Simple instructions and even has a bit more advanced coding in there to help keep you progressing in your game development! So cool!
Great videos! I have just finished watching all the videos in this playlist without even a break!!
wow dude i am new to coding (started yesterday)and brackeys are really helping me to create an awesome game
VERY COOL
Yep. Its a shame he and the team left to do other things, but this man was literally the only way i couldve started making games.
Good luck to you and your projects pal
I love the way you explain things, looking forward to supporting you on Patreon as soon as I get my first job :D
As a CS student who just studied function prototyping, invoking, parameters and signatures on C++
this video is PERFECTLY timed! Also yeah, I study C++ and C# at the same time :D
This is a great starting point for a power up system... However, in a larger game, one may consider pulling the Player Stats out into its own singleton class, but that gets quite advanced very quickly.
Well done bro. I now have my powerup working. 💥💥💥
Love your videos, they have helped me come so far as a programmer and game designer. I'm not sure if you take suggestions for videos, but i would love to see a tutorial which covers water/shaders/ripple&splash effects/swimming. The character could walk through the water and leave little ripples as they walk/ then a swimming & diving mechanic for when the water is deep enough. Keep up the great work!
what about using Invoke with a delay instead of the coroutine?
You can do it, but Invoke is very limited in comparison to Coroutine. So is better to undestand and use Coroutine bacause tomorrow you will use it all the time :)
You could do it with a delayed invoke to disable the power up. That would require you just an extra function.
absolutely beautiful! in my mobile game I also have power ups but the effects you put on yours really opened my mind man thank you! would love any thought on my indie mobile survival game if anyone has free time!
Avidi what’s ur game called
Days End
I'm looking for it but I can't find it. Is it on the google play store, or is it only for iPhone?
Oh im sorry! its not shipped yet, its on my channel tho
Oh I gotcha! I'll check it out!
for those who are getting this error
Library\PackageCache\com.unity.postprocessing@2.0.3-preview\PostProcessing\Runtime\PostProcessManager.cs(424,66): error CS0117: 'EditorSceneManager' does not contain a definition for 'IsGameObjectInScene'
update the package manager by going in Package Manager -> "In Project" and in that select Post Processing and then update it to the latest version
so 100hp * 1.4 = 140 / 1.4 = 100 Great, but what if you take damage?!?!?
Lets say you get your health up to 140 and than you take 40 damage and after the power up expires you end up with 71hp instead of 100. Is there a better way to do that?!
you would need to use a maximum health as well. after the duration reduce the max health back and if current health is > than max reduce current to max
before make changes on health, make a variable in the coroutine float healthbeforechanges = health;
after you can modify like *1.4
after the effect is done, just change current health with the variable healthbeforechanges
The health is only multiplied once so it would only be multiplied by 1.4 when you touch the power up, when you take damage it isn’t touch a power up so you don’t multiply
@@Dymangel This obly works if no other powerups were picked up during that time.
@@ДенисМаксименко-м9ц you could just store the difference in HP between the unmodified value and the value after multiplying it. and after the duration subtract the diff if it doesnt kill you/go lower than a fixed min value
This is super simple but very useful! And well organized!
This channel is the best.
Trank you gor this amazing Tutorial!
Simple and beautiful.
You can't go wrong with Brackeys :) Thank you for all you've done!
Oh My God! This tutorial is so awesome and insanely packed with useful informations that I love you more than ever, thanks for your work!
Again great content. Good quality and explaining several ways to use the power up!
thank you man you are the best explainer ever Love you brother
This tutorial helped me a lot. But the Particle pack did not go over well with my project, right after importing my project was unusable. So without the particle pack great tutorial :D
Great tut! Thanks! You make it look almost too easy!
Wow I miss Brackys videos they were so easy to understand
Your videos are amazing! If I had any money, I would donate to your Patreon. Thanks for inspiring me to learn more about game design, I was about to give up on trying to develop games before I found your channel!
Thanks! Do you have any plans on making a video about touch controls?
Same wish !
+1
Yeah he should totally do that
Touch control is simple, just look up the unity docs for "Input"
Thanks, i was searching for a timer of power up and you appear 😃👍
You legit explain well, thanks man
You could also control the power ups in a PowerUpScript inside the player. It would have a function that receives from the power up object the information about the variable to change, the amount and the duration and the PowerUpScript will take care of applying and controlling the duration. This way you can destroy the power up gameobject instantly.
I think it would be fun to have the power-up collider be a little larger than the pickup and on enter pull the power-up towards the player. Obviously it just depends what you're going for, but thought I'd share.
“Please don’t make fun of it”
I love your videos
Amazing videos will donate when saved up a little more
Best thing I've made was to subscribe to this channel
Keep going man!
Although the quality of the videos and the way he teaches/explains is superb I'm finding many of the latest videos too simple. Having simple stuff is good because it gets people started but some more complicated stuff every so often would be nice.
this
Problem is, advanced coding in unity usually means you are coding for a more unique task. This content is something everyone can use. He does have cool things like post processing and shader graph.
can you do a video on making a multiplayer (slpit screen, one keyboard or controllers) game kinda like this game
I love that Thumbnail!
Man ily Brackeys(no homo) you made everything seem so easy
Great video ^^ But i have one question. What do i do if i want to make a double jump power up?
It would be great if you did a quick tutorial on object pools. Don't want too many people thinking Instantiate and Destroy are good for a final build.
You are rock too with these awesome videos !
Good work! love your videos and tutorials but I have a request from you and that is can you please make a tutorial about IEmurator and Corutine so we all can understand what it is and how can we use it. I have been suffering a lot to understand this particular subject.
it will be awesome if you do that
thanks for the great videos and keep up the great work 👌
Coroutines are actually pretty simple once you understand them. Each coroutine has 3 basic parts:
1. Defining the coroutine. Do this like you would any other function. Just be sure to have the return type be an IEnumerator (it's what makes it a coroutine). Example: public IEnumerator myCoroutine().
2. Return an IEnumerator. All you need to do is return how long you want to coroutine to wait. The only special thing about it is that you have to write yield in front of it. Example: yield return new WaitForFixedUpdate(); There are multiple options for how long you want to wait.
3. Starting/stopping a coroutine. When you want to to start a coroutine write StartCoroutine(coroutine). When you want to stop a coroutine while it's running write StopCoroutine(coroutine) (you may want to do this when the game is paused for example). Example: StartCoroutine(myCoroutine()); StopCoroutine(myCoroutine());
So a typical coroutine might look like this:
public IEnumerator myCoroutine(){
//some code
yield return new WaitForFixedUpdate();
//some code
}
Here's how it works: When you start a coroutine it will act like any other function and start executing the code inside. Once it reaches a yield return statement, it will wait for however long you specified (seconds, end of frame, fixed update, etc.) and then it will continue executing the code after that yield return statement. Of course you can take advantage of this. If you put a while loop inside the coroutine, and have a yield return at the end of the loop, then the coroutine will wait for however long you specified before continuing. This effectually lets you control how often the while loop runs. You can also have more that 1 yield return statement if you want.
Actual example:
public IEnumerator boundCheck(){
while (Mathf.Abs(transform.position.x) < xLimit) { //&& same thing for y
yield return new WaitForSeconds(0.5);
}
Destroy(gameObject);
}
This coroutine will destroy an object once out of bounds. First I'll start the coroutine (probably in Start() for this one). Then in the while loop condition I check whether I'm within the bounds for the x-axis (xLimit being the boundary). If I'm within that boundary, then my coroutine will wait for 0.5 seconds. After waiting the coroutine will continue on from that line. Since it was inside the while loop, the condition of the while loop will be checked again. If it's still within that boundary, it will wait another 0.5 seconds. If it's outside the boundary the condition of the while loop is false, so the code moves on to where it Destroys the gameObject the script is attached to.
Thanks man!
I'm pretty sure you can run the power up reverse functions in a different thread so you can instantly destroy the game object when it is picked up and avoid disabling its components which I don't think is good practice.
your my hero thanks so much I finally understands coroutines, great vid!
Just a curiosity: Why can the PowerUp GameObject not be destroyed immediately? Since the effect has... taken effect, shouldn't the GameObject be moot at this point? Thanks!
love ur vids i will show u what i made u are the one who got me yo do unity
Hey could you do a tutorial on how to spawn randomly on a terrain? Even if it’s got hills
1) Generate a random X and Z, set Y very high
2) Raycast downwards.
3) Get the Raycast Hit, it will contain a point from which you can extract Y
4) Instantiate at X, Y, Z
Mr.K thank you my dude
You're welcome. Also note that there are a lot of ways to handle this. For example if you generate the terrain from a heightmap, you could read the elevation coordinates and completely discard the Raycast computation, and so on... Depends heavily on what you already got on your game.
If you in 2D
public class PowerUp : MonoBehaviour
{
void OnTriggerEnter2D (Collider2D other)
{
if (other.CompareTag("Player"))
{
Pickup();
}
}
void Pickup()
{
Debug.Log("Power up Picked up");
}
}
Why does this keep getting me error msges
Instantiate(pickupEffect, transform.position);
Hi Brackeys! I love your videos and this is a great one for the class I'm currently in. I have one question though. when I types out "PlayerStats stats" stats is greyed out and in stats.speed I am getting red lines. speed is in our player stats script I was wondering what I could do to fix this
Please make an vid about player possition saving!
That was just incredibly helpfull
LEGENDARY
Is there a difference from
if (other.gameObject.tag == "Player")
And
If (other.CompareTag("Player"))?
nah
@@hammythehamster5111 ok
There is. one is longer :)
The problem with the reversion of the power up here is that it's proportional to the /current/ health rather than the amount gained at the time of taking the power up. That could be intentional, but wouldn't it be better to store the amount of health gained by the power up in a variable then subtract the player's health by that number once the duration ends?
Just as an idea for a future project.. you could do something about a light system in 2D Unity games. I would love to see that :)
Would you please make a tutorail to combine various mesh and materials into single one?
thanks I really like yours videos
Brackeys you should use void On enter collider than on trigerr collider other
When removing the effect can't i just make a new function called normal and reverse the effect in it
And in the pickup method i just add invoke and the amout of seconds i want ?
Hey Brackeys, Can you make a video about creating a game similar to Worms Blast ?
You tutoreal is very gooood :D
Thanks bro.
Follow the steps carefully, step 1.. step 3... step 2.... ;-P
Only teasing.
As always, great tutorials fella, thanks for sharing :-)
Always subliminal with the tutorials man. I have a request though. I am working on 2D game in unity. Sample code below! The problem is that sometimes the delay time in the Invoke method gets skipped. The inconsistencies in the Invoke line of code is bugging. Please help. Sample code below! Thanks.
public GameObject[] points = new GameObject[6];
void Update(){
if(Input.GetKey(KeyCode.A)){
PointPlay(points);
}
}
void DelayMethod(){
}
void PointPlay(GameObject[] theArray){
int start_x = 1f;
int start_y = 1f;
for(int i = 0; i < theArray){
theArray[i].transform.position = new Vector3(start_x, start_y, 0f);
start_x += 2f;
start_y += 2f;
}
Invoke("DelayMethod", 2.5f);
}
Awesome video as always, but please start Android Game Dev tutorial series !!! Thanks for providing High quality content on YT :)
I love your vids man
Awesome man
This is nice, but a little simple. Personally, I would handle the effects in the player class, and have an enum in the power up class that defines buff types. The power up would pass the enum value as an int, along with the multiplier into a coroutine on the player.
Keep up the good work, but maybe elaborate a bit more next time, because I can see people taking this the wrong way, and having a separate class for each power up, encouraging bad habits and increasing compile times. Thanks!
Can you make a video about Unity animator and its functions? I mean stuff such interpole between animation, animation blenders and whatnot. There seems to be a lack of tutorial on this matter in RUclips. So, I hope you can cover them in depth. Awesome video as always! xD
love ya man.
Hey brackeys love your videos and i love the insight that you give I hope you can make make a video about setting an instance it a very common error that arrises atleast for me. For example i would be writing a script for rounds and in another script i want to go to the function inside the rounds script and set a new round with a function but when i do it the way i usually do it it gives me an instance error.
Wonderfull content and easy to learn as allways :D
OMG UR AMAZING I NEEDED THIS
Please make video on dynamic camera that u used in this game
Awesome video!!!
Can you do tutorials on making custom shaders?
Awesome! keep up on developing. love this tuts :)
Can I asked question?, ahm how can fix my multiplayer game because only one player can si the power-up I mean the effect of power but the other player can't see the first player power-ups and also this player can't see the object destroy after it pick-up? can you help me?
You wouldn't have to deal with the Mesh & Collider enabling if you handled the collision on the player instead of the powerup. It's also most logical, since only a player can affect a powerup and no other world object.
Great Tutorial! Just a quick note, you shouldnt be using a multiplier for something like health... if you have 140 health with the power up and lose 40 health during the effect.. you will end up with 100 and that gets divided by 1.4 the so you end up with much less health... you should compare if your hralth is higher than 100, then set it to 100. Else just leave it as it is :) thats how in my opinion is how its supposed to be in Games. Ofc that has nothing really to do with the tutorial, was just a quick note for game design ^^
FlexXx the health value he is modifying is most likely the max health. Current health would be stored in the main player class, or a game manager
Albarnie that makes it even worse :D ahen he loses health during.the powerup his max health gets very small afterwards
huh? just make it so on power down, if health is above max health, set it to max health. i dont see any problems with that
Albarnie well thats exactly what i explained ? Did you even read what i wrote xD?
I did, ive just come back to the issue after, like 3 hours. what you said is right, just maybe replace 100 with the max health variable for toggleability
Love the video as always
Peter Loch, you guys rock.
See what u did there buddy
The particle effect loops even though Looping is turned off in the effect prefab. Help?