Today with a small experimental tutorial about gravity.
So if you want to do a game about gravity, you are lucky because the corgi engine can cover that one.
So what we have here is our sample scene,
and I have just copied it with Ctrl D and have exactly the same scene again as same thing, just different name.
If you don't know how to set up a small prototype scene, then you can check my tutorial that I just did one week before.
If not, it doesn't matter because it works either way with whatever scene you have, as long as you have a character which can walk.
So I have here my pixie character which has the normal abilities that you have
when you create the character and do the out-to-build player character.
Yes, you have here your character, you can walk around, that's it, great.
Now first of all, what you need to do is to give our character our prefab, you should give him the ability for gravity.
which has the strange name of gravity.
How much gravity have I said in this tutorial until now?
And here you have different things which you can tweak around later.
And then we need a gravity field.
Let's start with the gravity field.
So you create an empty object and you call it very well and well our gravity field needs definitely a box collider which
should be triggered In this case,
I would also like to see, so let's create a sprite component, but this is purely optional just for myself.
As sprite, I have my pixel here, and I create that, let's see.
We can shift that here around and maybe put the set position.
And for the color, I would like to have it a little bit like that very well.
So you should see now here the gravity field and now let's add the collider that I just promised you before.
Here under the box collider 2D you should see as always the green lines around it to define where it starts and begins and here comes important part,
Make sure that you don't have a layer here like platforms or anything like that because else you will never get in,
you will always touch it.
we don't want that okay so let's save that great now just for cosmetical
reasons I will put that just a little bit
so that we see only where this force really will apply so now let's add the
gravity zone script to it and here is where the Okay, let's just try it out how it looks if we just play it.
So we have our layer which has now the ability to use gravity and look at that there is a small arrow
pointing down and here in the gravity zone you see a pointing up.
So you see where the gravity will apply.
And so if I jump in here, then you see I go into the field.
So before we go deeper into the gravity field configuration, let's talk about something.
If you have followed my tutorial step-by-step, then you should be where I am, right?
So at the moment, I'm working with WASD and I'm pressing only D.
And you will see now something you see in here,
how I go in and out, in and out, and if I leave it, then I go in and out.
So the reason is the moment I go into this gravity field, then the controls are now on the other direction.
So I'm walking here in and with the same button I'm going out.
I'm going in and I'm going out.
And that's the reason why you see all that.
For that you need to go to your prefabs and to the pixi correction.
and go down to your new ability which is called character gravity and just click here the gravity
reverse or resentful input when whatever comes next to that.
and you can read what it says if this is true horizontal movement the input will be reversed when
upside down so that means if i'm not lousy liar then it should work yes i'm pressing d
I'm still pressing the so I go into the field and down of the field.
Now we can start to check our gravity field configurations.
So if you have your gravity zone then you have a lot of change.
In this case you have gravity.
If go with the mouse onto it you see the force to apply vertically at all times.
So it means at the moment I was playing with minus 30.
So if I play with minus, oh come on, no risk, no fun.
So with minus 1000 then I think I will go up like it would be, I don't know, a magnet, a magnet.
So this is something you can tweak a little bit.
I minus 30 it looks reasonable.
But see you can really try to do something else so you can maybe move that up and make something like really.
like a magnet field or something like that if you would like to do so.
So I think this is the gravity and well you can also tweak around with the full
multiplier and the ascent multiplier in case you would like to
apply let's say he goes up faster than he goes down or something like that should
we do that why not let's fall with 10 and the cent with 0.5 now 0.1 I
really want to see it So I go here.
and you saw it was really quick.
Oh, I don't even have enough force to jump with this 0.1 for the ascent multiplier.
Don't forget the sand in this case, it's still the other way around, because yeah, because of gravity.
So the next family of configurations are for the speed.
the maximum loss so let's say I would like that he walks very slow here for whatever reason maybe you want to have
some honey on the top or something like that then let's put here five knock them on I really
want to feel it let's put the two So now if I try to walk in here,
then you see I cannot really be very fast.
It has nothing to do with anything else and just a limitation to it.
the next thing would be to tweak around here with the speed acceleration but in my case in my game there is no real acceleration.
I the acceleration is how long it takes until you reach the maximum velocity and in my case it's already very quick so it doesn't bring anything to do that.
if I go in here, then it's a normal speed, but let's go for 10, 100, you know I would like to exaggerate again.
So what happens, whoop, hahaha, we're in that, jump, whoop ah yeah.
So you see we can here tweak a little bit with the speed factor, it was one I guess.
So, the next thing would be slopes.
when you have the corgi engine, you define that you can walk on slopes and also depending which angle you would like to have.
And here you can tweak a little bit around to,
if you want to have a different value than you have with the corgi
I don't think that it really makes sense with my scene that I have here physics to the interaction
experimental no idea activated why because it's experimental The next thing to show is, I guess, down here where the gravity direction is.
I if you're interested in Gizmo's and really what this physics to the interaction means, well, we can talk about that later.
But here you can really put whatever angle you would like to have your gravity applied to.
And so we can go in there.
The last thing I would like to do with you is about the pixie and how he enters the gravity field.
but it has nothing to do with the gravity field itself, it has more to do with the character.
So when you have the character ability here, you have the transition and you can have reset, nothing, and adapt it.
I will put reset in here and show you something.
If I go in, look at that, it's and his shifted clock and he shifts.
It's not really, I don't know, not natural.
If you played something like Mario Galaxy then this is very stiff.
If your game requires that then you should have it.
I would go here for the transition to adapt and let's now check it again and then you see that there's just a smooth...
It's just a little bit smoother.
It really, it goes a little bit down before, you see, it just...
So the next thing is actually very easy to do and very quick, and there is not much configuration to do.
So let's create an empty game object.
with gravity point, not gravity false.
So I would like to have a sprite renderer to it, and I would like to have a round shape for it.
I don't know if you see that, but I'm really starting to think why the hell is he putting something in set manners?
I those things gives you problem with the time so...
please make sure that you don't have that okay so let's put it in here and let's
give him also a 2D collider so I was talking before about Mario Galaxy and I will do such a thing.
So is the planet and let's put that on platforms.
Let's save that and add the component gravity point and the only thing you can really do here is extend the distance of the effect.
And now, if I play, then you see I go here and I go here.
Now, what I had the trouble to find out why I had this issue was when I was just right under it, and I was pressing a double jump, then I just couldn't make it.
Try it for yourself and you see it's somehow difficult.
Sometimes just it works and sometimes it doesn't.
I didn't know what the reason was.
And the reason for that and how to fix it.
you go again to your pixie you go to your ability and in here there is the
experimental rotation and there is the inactive buffer duration if you click
in here he will tell you how long
he takes before he really accepts the soul and if i just put zero on it and it was experimental
and you know my rule experimental is don't do anything on it you should always follow the rules that you put on yourself.
So now I can do it without any issue.
That was it for gravity and this was the last time I mentioned that word.
So, thank you very much and see you next time for another, let's say, experimental approach to an ability.