#Game Help

1 messages Ā· Page 1 of 1 (latest)

keen valve
#

@flat nymph @sterile socket @outer jewel

#

So dlich you said don't let animation control logic

#

but how can i have certain things only happen during different states?

keen valve
#

i know that

flat nymph
#

I personally use a separate script for animation handling

keen valve
#

i have one for attacking

#

i have one for crouch attacking

#

when you walk, you run the walk animation

orchid matrix
#

easiest to handle animations inside coroutine

#

if you want it to get tied to a function

sterile socket
keen valve
#

when you jump, jump animation

#

ok

#

so then create seperate states for stuff like attacking

#

separate from your actual animation

#

this is getting WAY too off topic from my actual issue

orchid matrix
#

Actually, animation should be the last thing you want to add

keen valve
#

it

#

was

#

whatever

#

i get it. i did a lot of things wrong

#

but can you blame me? it worked and I'm new

#

it works great

flat nymph
keen valve
#

sucks that i have to redo it

#

YES

#

that is what i did

flat nymph
sterile socket
#

Write your logic as pseudo code or block diagram on paper first. Without considering animations at all. It would help us understand what kind of logic you want and then you can reference it when refactoring the code.

keen valve
#

ok

#

so what should i start with?

flat nymph
keen valve
#

i mean i have the attack code in a different script

sterile socket
#

Start with simple movement.

keen valve
sterile socket
orchid matrix
#

then have a state handler

keen valve
orchid matrix
#

then have bools for when you are in different state

#

like when attacking and is being attacked

flat nymph
#

I can't stress how much times I had to start a game from scratch, this isn't the same

orchid matrix
#

if any of those bools failed to check, dont accept input

keen valve
orchid matrix
#

any it is easier to read, really

orchid matrix
keen valve
#

because i know animator has bools too

flat nymph
#

I know I was late to the thread but did anybody debug any conditions?

keen valve
#

but i guess that's wrong

orchid matrix
#

if(attackscriptreference.IsAttacking)

outer jewel
#

Complete side note. I have a very hard time reading your code effectively - not judging just saying it is hard to read through so it is hard to help.

But, if you want to stop the player when they hit the ground after being hit, we should talk about that part a little bit more. Do you want them to stop cold and dead in their tracks?

orchid matrix
#

set animation bools as you change your normal bools. Then turn it off as it goes off as well

#

but dont make it rely on each other

outer jewel
#

If so, track when they get hit, and as soon as they land, set the rigidbody velocity to 0f and the angular velocity to 0f. Ugly but quick solution for the moment.

keen valve
orchid matrix
#

done make IsAttacking = IsPlayingAttackAnimation

keen valve
#

but that's not right

orchid matrix
keen valve
flat nymph
#

track when the player gets hit midair, once it reaches the ground, make the rigidbody velocity to 0.

keen valve
#

doesn't call the bool

orchid matrix
#

not the script

sterile socket
#

If you really want to eliminate the root of the problem, you should refactor you movement logic.
As I said previously, start with defining your logic on paper.
As it is now, a quick fix would fix your current problem in the best case. In the worst case, it would create more bugs.

orchid matrix
#

you need to get a field reference, then connect them

keen valve
#

idk what that is

orchid matrix
#

public Attack attack;

keen valve
#

Attack is the script

#

it's the name of the script

orchid matrix
#

then drag the proper script in the inspector, or use GetComponent<>

keen valve
#

wait i think i know what you mean

#

you mean like this?

flat nymph
#

@keen valve as dlich said before the thread, always make your animations depend on movement, not the other way around

keen valve
#

@orchid matrix ?

#

got it

#

i'm trying to fix that now

flat nymph
#

yes.

#

And also, just to re-summarize your problem was that you kept moving when attacked midair? @keen valve

keen valve
#

when you land on the ground, you don't stop moving

#

but only if you're hit in midair

outer jewel
#

It's probably caused by ~line 240, where if you get hit, it keeps applying velocity

flat nymph
#

anyways @keen valve

#

i have to go

#

but keep us updated

keen valve
#

ok thx

keen valve
#

also lemme resend a sorta update code

#

for movement

outer jewel
#

You could add a book at the top
bool hitInAir = false;

Then in the Update

if(!hitInAir && !isGrounded && isHurt)
  hitInAir = true;

if(isGrounded && hitInAir)
{
  hitInAir= false;
  rgbd.velocity = 0f;
  rgbd.angularVelocity = 0f;
}
#

Changing those variables to the proper ones mind you

keen valve
#

now i can't climb steps

#

(cries)

#

and to make matters worse, i'm back to just moving constantly when hit

#

great. more issues lol

#

guys?

outer jewel
#

I provided my two cents, I can't help more without rewriting it, and I have to move on with my evening

keen valve
#

ok.

#

can anyone help me tomorrow?

#

because now it just got worse

sterile socket
outer jewel
#

You can always ask from help, it doesn't have to be any specific person helping

keen valve
#

ok

sterile socket
keen valve
#

because now i can't climb steps

outer jewel
#

But the reason it is so fragile is because it does need a cleanup and rewrite.

A small way to get started is just to let visual studio fix the indentation for you

keen valve
#

i'm doing what lyxerel said

sterile socket
#

No you didn't. At least not the way I meant.

keen valve
#

and what you said

#

i feel sick

sterile socket
#

I suggested to step back from your code, write down your logic. Then move to refactoring(honestly, rewriting from 0 would be better)

keen valve
#

please don't do this to me

#

i have so much else to do

outer jewel
# keen valve how does it do that?

You are embedding many ifs within ifs. Without proper indenting it is hard to tell what belongs to what.

Cleaning that up helps with readabiliry.

keen valve
#

i can't rewrite my entire script.

#

there has to be another way

sterile socket
# keen valve please don't do this to me

Lol, that would be the easiest way to solve all your issues. And any issues that might come in the future with the current setup.
But suit yourself.šŸ¤·ā€ā™‚ļø

keen valve
outer jewel
#

Control A + Control K would normally auto indent

#

I'm suspecting you aren't using git though or source control. So it is probably hard to backtrack and try things

sterile socket
keen valve
#

it just needs some tuning

sterile socket
#

Clearly not

keen valve
#

i followed tutorials

#

i did everything

sterile socket
#

If you did follow a tutorial, then why are there issues?

keen valve
#

can't I just, like, rewrite certain aspects of it?

sterile socket
keen valve
#

i feel so sick to my stomach

sterile socket
#

If your code was not spaghetti. At the moment everything is intertwined and related.

#

If you rewrite one thing something else would break.

keen valve
#

and again, if i do rewrite it, what's to say it won't look the same?

sterile socket
#

Well, this time you could ask feedback from experienced people from time to time and they will direct you to writing a good code.

keen valve
#

i did

outer jewel
#

I think it would take me all of 5 minutes to rewrite it.. but then you aren't getting the most out of your classes.

keen valve
#

yeah

#

i mean

outer jewel
#

And walking through what I would change and why, is a laborious process. Especially over discord.

keen valve
#

and again, i don't want to change it because it works fine

#

or at least it did

outer jewel
#

All you need to do, is what I shared up top. Track when you are hit in the air. And when you hit the ground zero out the velocities.

#

But with the code how it is, it may break other things, and that setting may get ignored and overwritten.

keen valve
#

ok

#

i don't want to completely rewrite the code

#

is there a way i can, like, clean it up?

sterile socket
# keen valve i did

I'm not sure about it. At least the way it is now doesn't look like you were given any advices on good code structure. Or you didn't follow any.

keen valve
sterile socket
#

What exactly did you ask though?

#

How to fix a bug, right?

keen valve
#

yes

#

and yes, i did ask for help here multiple times and i did follow their help

sterile socket
#

Then you were asking the wrong questions. I bet all you got were quick fixes that only made your codebase worse.

keen valve
#

dang

sterile socket
#

If you have any desire to make it right, I'm willing to walk you through the correct process of writing your code.

#

If not, then keep on looking for quick fixes.

sterile socket
#

Depends. Shouldn't be more than a day or 2. Can be a few hours if you're quick.

keen valve
#

okay.

#

can we do it tomorrow then?

#

when are you available?

#

@sterile socket actually idk

#

i'm kinda torn

#

i'm so torn here

#

because then wouldn't it just be, like, you writing the whole thing for me?

sterile socket
#

You don't need me available. Just follow the steps and report them here. Then I'll give you some feedback and we can move to the next step if there are no problems.

keen valve
#

what steps?

#

i'm so lost

sterile socket
#

Step one : write your logic down on paper.

#

Or text file

keen valve
#

ok i'll write notes on my phone

sterile socket
#

Either would do.

keen valve
#

how exact should they be?

#

like
when you move left/right, you move left/right?

#

here's the thing

#

i already have an input handler from my class

#

i'm using that

#

so I'm keeping that

sterile socket
#

It would be best if it's in the form of a block diagram or pseudo code.

keen valve
#

alright. i'll see what i can do

#

but i really hope you'll be available when i'm ready

#

even though i REALLY don't want to do this

sterile socket
#

I'm at work, but I can have a look any time.

keen valve
#

ok but, like, if we can get it done by maybe next week? if not, i'm just gonna have to keep using the old code

#

because i really can't afford to waste anymore time

sterile socket
#

If we're not done by Saturday/Sunday we can jump on a call, but I'm certain that wouldn't be necessary.

keen valve
#

But if we can do it quickly and it’s simple and it’ll still work and I do most the coding then I think it’ll work

sterile socket
#

A. It's very necessary. You might not realize it now, but your code is super complex for a very simple task making it very hard to debug and opening opportunities for new bugs.
B. I'm not gonna write anything
Only guide you to a correct implementation. You might as well learning something from that.

keen valve
#

I just don’t want to waste a lot of time on something I already did

#

When I still gotta do stuff like design the level, add textures, cutscenes by mid April

orchid matrix
#

Decided to refactor? That's nice

keen valve
#

I’m still thinking about it

#

But I’ll need your guys help

outer jewel
#

I'll be honest, him volunteering his time to help you move forward - that's a mentorship opportunity you won't get often in life.

orchid matrix
#

if you are serious into game deving, practicing to make your code more readable is never waste of time, ever

keen valve
#

Okay so for the movement I gotta
-Move left and right
Jump with no midair movement
-Crouch
-climb steps

#

Yes. Thank you guys

#

I am serious with game design

orchid matrix
#

Im just 3 months into it, but if you compare my first prototypes, youll dump it in the garbage on first glance

keen valve
#

So I hope I can make this work with your help

#

But if it’s just the movement code and we do it quickly and I have your help, let’s start tomorrow

#

I’ll write some of the pseudo code tomorrow, send it to @sterile socket or maybe I can tag you guys in this thread and get some input

#

If that’s alright?

#

Thanks guys. Sorry if I’m stressing a lot. This is a very important project.

#

It’s my senior capstone

orchid matrix
keen valve
#

Ok. Due mid April I believe

#

Early-mid April

#

So if we can get the movement code reworked by, say, the end of next week I might still be on track

#

Is it okay if I DM any of you too?

#

@sterile socket or just post here in the thread?

orchid matrix
#

Here is enough so we can all see your progress

keen valve
#

Ok. Can I tag you with updates too?

#

I just wanna make sure I get it done in time

sterile socket
flat nymph
#

@keen valve Rewriting efficient code should not take more than 2 days

#

We can help if u want

keen valve
#

Thanks. I didn’t sleep last night because I’m so stressed. I’ll write the pseudo code today and send you when I’m done

keen valve
#

@sterile socket @flat nymph @orchid matrix @outer jewel i'm not really skilled at writing pseudocode but I hope this is a good start.
It covers basically everything that the original code covers but more simplified and hopefully explained better

#

oop i forgot to add some stuff for vertical movement. add private float vertical and set it to
_input.InputVector.y; in update

keen valve
#

Hey! Just reminding I posted the pseudo code

sterile socket
#

Please calm down. You can't expect people to be available 24/7.

sterile socket
# keen valve <@209684227720085505> <@1015230037697499147> <@456226577798135808> <@22930206184...

Ok. This is not exactly what I expected. It looks like you just took your script, went through it and rewrote it in other words. What I asked you to do is think of the simplest logic of your program and write it down(no looking at the script). You don't need any variables, method names or anything. Only the logic flow.
For example:

//Movement
    If knocked back
        Do nothing
    If grounded
        Process horizontal movement
    Else
        Process jump movement

Think of what you want to happen in your game and try writing down all your logic in a similar way.

keen valve
orchid matrix
# keen valve <@209684227720085505> is this better?

hmmm.. put everything in branches. When writing a pseudocode, the most important is you know where you are in the code. You just listed all the capabilities of your character but currently there is no chain of what can happen and when it should happen.

keen valve
#

Example?

orchid matrix
#
STATE CHECK
STANDING
    CAN ATTACK
    CAN JUMP
    CAN CROUCH
CROUCHING
    CAN ATTACK
    CAN JUMP
    CAN STAND
JUMPING
    CAN JUMP(DOUBLE)
    CAN ATTACK```
A pseudocode can be as simple as this
#

then you keep extending the branches

keen valve
#

Because I did put each one in different categories like (MOVEMENT) and (JUMPING) is that what you mean?

orchid matrix
#

Yea, you never know what will happen, you just make an outline on how will you write the code

keen valve
#

Ohhh let me try

#

probably not right? is there anything i should change?

orchid matrix
#

remove all the Can't Lines, you dont need it and it unnecessary makes things complicated

keen valve
#

oh so just the Cans?

orchid matrix
#

ye

#

just make sure you write everything you "can" do at any time tho

#

anyways you can easily add them later

keen valve
#

anything else i should change?

orchid matrix
#

Now decide what are the extra conditions is, you have a IsHurt before right

#

what will it limit

#

what "cant" you do while hurt

keen valve
#

you told me not to tho?

#

oh wait you mean, like, stuff you can't do for states like climbing, attacking, or getting hurt?

orchid matrix
#

They are supposed to go here

#

if ishurt, then do something

#

if not then something else

keen valve
#

idk. i don't think i did it right?

sterile socket
#

It's still too complicated and a lot of unnecessary text.
This

(CROUCHING)
    CAN JUMP
    CAN ATTACK    
    if down arrow key pressed{
    crouch
    play crouch animation
    you can't move while crouching
    }

Can be rewritten as

If Crouching
    Process crouching

No need to specify what you CAN or can not do here. This should be obvious from the conditions of the other state:

//When processing movement
If not crouching and not in the air
    Process horizontal movement
keen valve
#

ok

orchid matrix
keen valve
#

hmmm that seems too complicated. this is supposed to be simple, yes?

sterile socket
#

We're still talking about pseudo code. The actually implementation doesn't matter here. I just want to strip it all to bare bones logic.

orchid matrix
#

Anyway, I guess I ll just watch hehe, I am actually doing my game as well so I might be unresponsive and cant help much anyways hehe

keen valve
#

good luck! if you help out too as well when you can I'd really appreciate it!

#

anyways dlich, is the pseudocode better?

orchid matrix
sterile socket
# keen valve <@209684227720085505> better?

This is better. But essentially, your movement logic is just this part:

(MOVEMENT)
    if not attacking, climbing, crouching, hurt, or in air{
        process movement
    }
    if climbing{
        process going up steps
    }
keen valve
#

is that not right?

sterile socket
#

It is right. I'm just telling you, that the essence of your movement logic is just these few lines.

That being said, what about when the character is in the air? Does it not move at all? How will it get to the ground? Same about other states. Does the character not move at all there?

keen valve
#

how do you get to the ground? use gravity. use the groundcheck i put in there

sterile socket
sterile socket
sterile socket
#

That sounds like movement to me.

keen valve
sterile socket
#

That. But you should also include the effect of gravity in your logic. Since it affects your movement(it doesn't matter if you do it manually or let unity handle it).

#

Your logic needs to describe the character movement in it's entirety, regardless of where it originates from.

sterile socket
#

Ok, let's leave it like that for now.
The horizontal input line is unnecessary as it's about specific implementation, which we don't want here, but I'll just pretend I don't see it.

Now, what about when the character is knocked down? Is it not supposed to be moved back or something?

keen valve
#

yes

sterile socket
#

Shouldn't that be in the movement logic as well?

keen valve
#

I made a separate one for knockback

#

but i should put that in movement as well?

#

i was thinking: you're basically just jumping just in the opposite direction

sterile socket
#

Let's clarify one thing. When we're talking about "movement" in a game, we refer to change in position over time. Regardless of what's causing it.

keen valve
#

oh

#

so...

#

get rid of knockback and put it in movement?

sterile socket
#

Movent is not only when you press the arrow buttons

keen valve
#

should i do the same with jumping?

sterile socket
sterile socket
keen valve
#

same with jumping?

#

what about....

#

ground check?

#

or steps check?

sterile socket
#

Does it change the position of your character?

keen valve
#

i don't think so

sterile socket
#

Then, no

keen valve
#

it's just checking if you are on the ground

#

or climbing steps

keen valve
#

also give me, like, a half hour. my laptop's battery is running low. but i'll be back in, like, a half hour

sterile socket
#

Alright.
Let's have a look at this part:

if not attacking, climbing, crouching, hurt, or in air{
        process horizontal movement
        horizontal movement from horizontal input * movespeed
        vertical movement from gravity 
    }

Specifically, it's condition. It seems to be safe to say, that the only time we want horizontal movement processed is when we are not in any of the other states, right?
In this case wouldn't it make sense to express it like that?

If Crouching
    ...
If Knocked
   ...
//If other relevant states
   ...
Else
    Process horizontal movement
keen valve
#

@sterile socket okay I’m back

#

Ohhh ok

sterile socket
# keen valve Ohhh ok

Further more, all of the states have something in common. They calculate the movement of the character in that state and apply it to the character. In your script you were using velocity for that. Since in the end they're all doing the same thing(applying movement), we can take it out of the states and place it at the very end of the logic. This way we will be sure that our movement is always processed, regardless of the state. And judging on its value we would be able to make assumptions on what went wrong when we face a bug.
So to sum it up we can write it in a similar fashion:

//We start with no movement at all. Alternatively/additionally we could take into account the movement from the last frame
Movement = none
//Then we add up movement based on the current state of the character
If Crouching
    Movement += Process crouching
If knocked
    Movement += Process knocked
...
Else
    Movement += Process input
//Lastly we apply the calculated movement
ApplyMovement(Movement)

Does that make sense?

keen valve
sterile socket
#

Exactly.

#

If you don't want to move at all, you just apply no movement.

#

Taking that into account rewrite the movement logic pseudo code.

keen valve
#

@sterile socket you there?

keen valve
#

hey bro, i'm gonna go to bed in, like, an hour. if this pseudocode looks fine, you want me to, like, get started setting up the code or do it tomorrow?

#

cause, like, if you're busy now, that's fine. we can always pick it up tomorrow. i just wanna make sure the pseudocode is fine and ready for getting started on the actual coding tomorrow. šŸ‘

sterile socket
#

Why is the climbing in the else block here and not outside along with the other states? Is there any special reason for that?

    Else{
        if not climbing {
            process horizontal movement
            horizontal movement from horizontal input * movespeed
            vertical movement from gravity 
        else if climbing {
            process horizontal movement from horizontal input *                 movespeed
            process vertical movement from vertical input
            no gravity
                }
    }
keen valve
#

But if that’s not right I can move it

sterile socket
#

It might be similar from the perspective of gameplay, but logically, it's a totally different state that should be treated o. Equal terms as the other ones.

keen valve
#

Okay lemme change it then

sterile socket
# keen valve aight how's this then?

Ok, so looking at all this states of Movement, is it correct to say that only one of them is active at the same time?

(MOVEMENT)
Movement = none;
    if Jumping{
        if you are on the ground and not hurt {
            movement += procress jumping
            no midair movement. moves in direction when jumping                 while moving
        }
        if on ground{
            movement += process landing
            stop jump animation
        }
    (KNOCKBACK)
    if is hurt{
        movement += knockback
        similar to jumping just in different direction
    }
    (DIRECTION CHANGE)
    if right arrow key pressed {
        face right
    }
    if left arrow key pressed {
        face left
    }
    (CROUCHING)
    if crouching{
    movement += process crouch 
    }
     if climbing {
            process horizontal movement from horizontal input *                 movespeed
            process vertical movement from vertical input
            no gravity
                }
    Else{
            process horizontal movement
            horizontal movement from horizontal input * movespeed
            vertical movement from gravity 
        
    }
Apply Movement
keen valve
#

Well, I mean, you can attack when you move. But you stop moving when you attack. You can attack while in the air too

#

Think that’s what lyxerexyl was saying when he said make a flow

sterile socket
#

You're mixing up things again. We're talking about movement only now. It doesn't matter what else you can do in these states.

keen valve
#

Oh

#

Can you rephrase your question then?

#

You’re saying only on state is active at a time?

sterile socket
#

Yes.

keen valve
#

So, like, when I’m attacking, I’m not doing anything else?

sterile socket
#

Attacking is irrelevant here, as it's not a movement state

#

Or is it?

keen valve
#

No

#

Wait I’m confused with what you’re asking

sterile socket
#

Can you both crouch and move normally horizontally for example?

keen valve
#

Oh. No but you can jump when you crouch

sterile socket
#

Jump, knockback, crouching, climbing, normal movement. Can any of these be active at the same time?

keen valve
#

No

sterile socket
keen valve
#

Yes we’ll actually my jump animation is the same as my crouch animation

sterile socket
#

I told you before, forget about animations. We're only talking about movement.

keen valve
#

Ok

#

Well then yes you can be crouching when in the air

sterile socket
#

How is it different from not crouching while in the air?

keen valve
#

It’s not

#

So I guess technically you… aren’t crouching while in the air?

sterile socket
#

Then in what sense can you be crouching while in the air?

keen valve
#

Fair point

sterile socket
#

Anyways, it seems like you can only be in one of these states at a time. That means that we can use a simple state machines to handle them.

#

Do you know how to use enums?

keen valve
#

Ok

#

No

#

Well

#

Sorta

#

I’ve practiced with them but I’m a bit rusty and i haven’t done it in unity

sterile socket
#

Well, you'll need to refresh that as it's the simplest way to implement a state machine.
Enums and switch statements.

keen valve
#

Alright

sterile socket
#

The general idea is like that:

switch(current state)
{
    Case state0:
        Movement = ProcessState0()
    Case state1:
        Movement = ProcessState1()
    //Etc
}

This is pseudo code. You'll need to use correct syntax for switch statements.

Current state should be an enum that you made for all the states we were talking about until now.
You would go through all of your checks and assign the current state of the frame.
Then this switch statement would be calling the appropriate method depending on the current state, to process and calculate the movement. Finally you apply your movement in the end of update.
Makes sense?

keen valve
#

Yeah I’m looking at guides for it now

#

So you want me to rewrite the pseudo code again for this?

#

Make it a switch statement using enum?

sterile socket
sterile socket
keen valve
#

But see this is where I’m confused

#

If using an enum and switch statement, how will it activate stuff like if I’m pressing the jump button?

#

Lemme write it out so I can show you if I have the right idea?

#

@sterile socket so do you mean something like this?

sterile socket
keen valve
#

Oh yeah

sterile socket
keen valve
#

So if I press space, I’m putting it to the jump state?

sterile socket
#

Yes.

keen valve
#

Same with stuff like climbing steps

#

If pressing up or down while touching steps, I’m in the climbing state

sterile socket
#

Yes. Obviously, it's not gonna be as simple as just checking the input. You'll probably need more conditions.

keen valve
#

Oh. Such as what?

sterile socket
#

Such as the current state, grounded/hurt/current movement and any other checks necessary to decide whether you should change state and if yes, what state to.

keen valve
#

Getting lost again lol

sterile socket
#

To put it simply:

  1. Check if we should change state, and change if necessary.
  2. Process the state.
keen valve
#

Okay so, like,
If space is pressed
If is grounded
Change state to jump

sterile socket
#

If on the last frame you were moving normally, but this frame you got hit, then you know that you should change to knockback state.

keen valve
#

So
If hurt
Change to knockback state

#

If moving
If hurt
Go to knockback state

#

Should I put those in the pseudo code or just when we get to actual coding?

sterile socket
#

It's fine to put it in the actual code.

keen valve
#

alright. i'm still a bit confused on it but we can work it out during the coding ig.

sterile socket
#

The pseudo code gets unwieldy anyway. There's no much point in it anymore. Maybe block diagrams would've been better...

keen valve
#

ah. so the pseudocode isn't good then ig?

sterile socket
sterile socket
keen valve
sterile socket
#

Leave it as it is. You can still reference it when coding.

keen valve
#

but, like, i guess it's more an animation issue

#

like if you jump, you start off from the ground. so if i call the jump state, you will be on the ground when you jump

sterile socket
keen valve
#

yeah ig

#

but i also followed a youtube tutorial on it as well

#

and stuff like the walk animation is determined by your movement

#

and jump/midair animation is based on if you're in the air

sterile socket
keen valve
#

gotcha

sterile socket
keen valve
#

like, i get what you're saying. it makes sense. i guess i'm just having difficulty imagining how it's gonna be written. but again, i guess we'll have to see when we start with coding

#

and pseudocode can help with it too

keen valve
#

anyways @sterile socket it's getting late here and i gotta go to bed. but do you want to continue this same time tomorrow? i'll let you know when I'm ready and when you're ready we can get started. thanks fo much for your help!

sterile socket
#

It's more convenient for me in 6-7 hours from now. That's when I have some free time.

keen valve
#

i'll be in bed that time lol

sterile socket
#

But I'll reply whenever I have time either way.

keen valve
#

okay. i'm thinking maybe same time as today. like around six or sevenish for me. what timezone are you?

#

*p.m.

#

*rn it's 11:49 at night for me

sterile socket
#

It 2pm here. I'm at work around this time.

keen valve
#

i'll also message some of the other people in this thread too

flat nymph
#

Heyo

#

what did i miss

#

Judging by previous messages the drastic time zones are a problem šŸ’€

#

Anyways @keen valve how's your pseudocode going?

keen valve
#

Gonna hopefully see if I can get his help later today

sterile socket
#

Just in case, I'm available now for an hour or so before I go to sleep, so if you have any questions, now's a good time.

keen valve
#

Oh I’m sorry I didn’t see this. But I’ll try again later today after I’m done school

keen valve
#

@sterile socket @flat nymph @orchid matrix @outer jewel Yo! Anyone up for helpin with the movement code?

#

Last time, dlich suggested using a state machine using enum and switch statements

#

My main issue is going to be how it’s going to work. As well as stuff like actually moving the player and jumping

orchid matrix
#

I am in class today, might only just visit from time. Can help you timely though, where is the latest pseudocode now?

keen valve
#

well the finished one i posted last night

keen valve
orchid matrix
#

your night? šŸ˜„

keen valve
#

yes my night lol

#

timezones are a bitch XD

orchid matrix
#

have you created the enums already?

keen valve
orchid matrix
#

What is these 2```cs

public Hurt hurt;
public StepsCheck stepscheck;
keen valve
orchid matrix
#

also put comments on variable that you assigned already but havent used yet```cs

private float MovementSpeed = 3;
private float horizontal;
private float vertical;
orchid matrix
#

nvm, it may be more organized if you do that

keen valve
#

they're scripts for certain things i made before we started doing this

keen valve
#

so if i wanna check to see if i got hurt, call the hurt state from the hurt script

#

same with the attack state

#

so now my main issue i guess is what's going to go where, and what i'm going to use for movement? physics? transform?

#

do i use what i used before? or was that too complex?

orchid matrix
#

transform movements are more flexible because you do all the logic

keen valve
#

okay then i should use physics

#

well it's simple movement i guess so physics might be the better way to go

keen valve
orchid matrix
#

wait were calling attendance hehe

keen valve
#

who your class?

orchid matrix
keen valve
#

but again, i might be remembering it wrong

orchid matrix
#

did dlich already give a go to start coding?

keen valve
#

yeah that's what i'm doing now

orchid matrix
#

nice, okay

keen valve
#

i showed you what i have so far with coding

#

i'm waiting on dlich too to get his input as well

orchid matrix
#

first make a method that will do the stuffs your character will do

#

ie. jump(), crouch()

keen valve
#

well we're doing enum and states

#

switch statements

#

he also said to take into account other logic for states like if you're on the ground

orchid matrix
#
    if Jumping{
        if you are on the ground and not hurt {
            movement += procress jumping
            no midair movement. moves in direction when jumping                 while moving
        }
        if on ground{
            movement += process landing
            stop jump animation
        }
```you can start by making this into a sinple method
keen valve
#

since you're really only doing one at a time

orchid matrix
#
    void jump()
    {
        if(all conditions that should be true) // if any is false, you cant jump
        {
            // what happens when you jump
        }
    }```
keen valve
#

honestly, i'm fine with either method.

#

as long as it works and it doesn't look too cluttered

orchid matrix
#

that wont conflict, with his idea

#

im following a state machines as well

#

anyways, I think im bad as teacher, im just directly telling what to do

#

we should just wait dlich, he is about to go online around this time anyways

keen valve
#

hmmm well i already have the enum set up

keen valve
#

in, like, a half hour

orchid matrix
#
void UnitHour() 
    {
        switch(currentstate)
        {
            case State.Idle:
                if(target != null)
                {
                    attack();
                    move(target.transform.position, -1*speed);
                    currentstate = State.Attacking;
                }
                else if(moveposition != (Vector2)transform.position)
                {
                    currentstate = State.Moving;
                }
                else if(isReturning || gunBroke)
                {
                    stateChange("Returning");
                }
                else
                {
                    moveposition = restoreposition;
                }
                break;
            case State.Moving:
                if(target != null)
                {
                    attack();
                }
                move(moveposition, speed);
                
                if(moveposition == (Vector2)transform.position)
                {
                    if(target != null)
                    {
                        strafe();
                        currentstate = State.Attacking;
                    }
                    else
                    {
                        currentstate = State.Idle;
                    }
                }
                Drawline(moveposition);
                break;``` this makes things organized by making the methods that `do` stuffs separate. This wont hurt a statemachine
#

that is a script from what im currently working on, this is not accepting input, but you can simply add them inside the methods()

sterile socket
# keen valve https://gdl.space/nayuxohomu.cs

You might need to add additional states as we go. But add the normal movement(horizontal movement) one now.

We want to put the switch statement in its own method. Let's call it UpdateState.

#

Then we'll also need another method for changing between states. That can also be in a separate method and it will also need the same switch statement as what state we can change too would probably depends on the current state.

keen valve
#

@sterile socket @orchid matrix i'm back

keen valve
sterile socket
keen valve
#

ok

sterile socket
keen valve
#

it is?

#

my bad lemme change that

#

okay so, then, shall I add the groundcheck next?

#

that would be a collission check, yes?

sterile socket
#

Add where?

keen valve
#

I was thinking a OnCollissionEnter2D

sterile socket
#

Hmmm... I think it's better to do a raycast every frame.

keen valve
sterile socket
#

I don't remember what you were doing before, but I guess so.

keen valve
#

private bool isGrounded()
{
float ydirection = transform.position.y - groundCheck.position.y;
if (ydirection >= 0)
{
return Physics2D.OverlapCircle(groundCheck.position, 1.01f, Ground);
}
else
{
return false;
}

}
#

oh man, and we just learned about this in class too lol

#

lemme check that code

#

waiting for that to load

keen valve
sterile socket
#

Why transform.forward?

keen valve
#

i guess maybe if you land on your feet, the bottom of your character? idk.

sterile socket
keen valve
sterile socket
keen valve
#

but according to this guide i'm reading, the parameters are the origin, the direction, and max distance

sterile socket
keen valve
#

idk. the bottom of the player?

#

or the direction of the player?

sterile socket
#

What is transform.forward? Where does it point?

keen valve
#

forward?

sterile socket
#

Okay. So then, how is that related to a ground check?

keen valve
#

it's not

#

so maybe make it so it's checking, like, your feet?

sterile socket
#

Yes.

keen valve
#

how would i do that?

sterile socket
#

What's the relevant direction?

keen valve
#

down

sterile socket
#

Yes, but is it available as it is as a property/field of Transform?

keen valve
#

no

sterile socket
#

What axis is the down direction on?

keen valve
#

up?

sterile socket
#

If that's the answer to the first question, then yes.

keen valve
#

but i assume the green axis?

sterile socket
#

And what do we call the green axis?

keen valve
#

y

keen valve
sterile socket
#

Correct. That was a leading question to the first one though.

keen valve
#

so... the direction parameter would be transform.up?

sterile socket
#

So you use transform.up to get the down direction.

keen valve
#

ok

sterile socket
#

You don't just use it as it is.

keen valve
#

dammit

sterile socket
#

Down is obviously opposite to up

keen valve
#

-transform.up?

sterile socket
#

Yep

keen valve
#

okay so how's this?

sterile socket
# keen valve okay so how's this?

That would do. Maybe tag checking is not the best way but you can deal with it later. Also, if you're checking tags,it's preferable to use CompareTag method.

keen valve
#

let's deal with it now just to get it out of the way

#

then let's do checking if colliding with steps

#

which would that be a raycast too?

sterile socket
keen valve
#

what about oncollisionenter

sterile socket
#

That would imply that your ladders have colliders and don't let the character walk through them.

keen valve
#

so ontriggerenter would work

sterile socket
#

Yes. You can deal with all of that later. Focus on getting the basics movement working first.

keen valve
#

alright

#

let

#

s start with moving on the ground

#

which is here, right?

#

is that in updatestate or changestate?

sterile socket
#

Right. Create a method specific to that state update and call it from here. Then put your movent logic in that method.

sterile socket
keen valve
#

ok

keen valve
sterile socket
#

Put it in its own method

keen valve
#

oh

#

huh?

#

you mean like this?

#

then call that in the state?

sterile socket
#

Yes. Do you remember how we said that the states should only calculate the movement and not apply it?

keen valve
#

okay so... should I test to see if it works or is there more I should add for it?

#

just to see if basic movement works

sterile socket
# keen valve yeah

But you are applying it right here. Instead, you should return a Vector2. And apply it to velocity after the state machine update.

sterile socket
sterile socket
#

About what?

keen valve
sterile socket
#

Which part exactly?

keen valve
#

so return a vector in the movement method?

sterile socket
#

Yes

keen valve
#

or in the state machine?

sterile socket
#

Both

keen valve
sterile socket
keen valve
#

return

sterile socket
#

That's only one part of it.

keen valve
#

oh

sterile socket
#

What's the void at the method declaration for?

keen valve
#

it doesn't return a value

sterile socket
#

To be more precise, it's the return type of the method. Void means that it's none.

#

What type do we want to return?

keen valve
#

idk

sterile socket
#

What are we returning?

keen valve
#

a vector2

sterile socket
#

And Vector2 is what?

keen valve
#

vector

sterile socket
#

No. In C# terms.

#

Or even in object oriented terms

keen valve
#

a float?

sterile socket
#

No, but ok. What's a float then?

keen valve
#

a floating point number

#

has decimals

sterile socket
#

When you declare a variable like that: float a. What is float in this case? Why do we need it?

keen valve
#

in case integers don't work

#

if the number you're calling isn't an integer

sterile socket
#

Ok, but why do we need it there?

#

Why not double a then?

keen valve
#

it's simpler

#

it's not as big

sterile socket
#

What this Something in Something a when we declare a variable?

#

What does it tell about the variable a?

keen valve
#

that's it's something?

#

anyways we're getting way off topic

sterile socket
#

We're not. You're missing a very key important point here. It's so important that I'm surprised you were able to code so far...

keen valve
#

i can. i'm just blanking out rn.

sterile socket
#

Ok. Google on how to declare a variable in C# and what each part of it means.

keen valve
#

type is the type of variable
name is the name of the variable

the value of the variable

#

type name = value

orchid matrix
#

just done class, what's happening?

keen valve
#

dlich is teaching me what a vector is

orchid matrix
#

yea I can see haha

sterile socket
#

Good, so going back to float a what is float?

keen valve
#

so we can figure out how to return a vector

keen valve
sterile socket
keen valve
sterile socket
#

Good

#

It's a type

keen valve
#

yes

sterile socket
#

Then what is Vector2?

keen valve
#

type

sterile socket
#

Correct. Now, going back to where we started, what type do we want to return?

keen valve
#

vector2

sterile socket
#

Or rather, variable of what type.

#

Correct.

keen valve
#

yeah but

sterile socket
#

So how do we declare the method to return a Vector2?

keen valve
#

that's what i'm trying to figure out

sterile socket
#

What void means again?

keen valve
#

none

sterile socket
#

None what?

keen valve
#

no return type

sterile socket
#

Yep. So what do we change it to to have a return type?

keen valve
#

vector2

sterile socket
#

Correct.

keen valve
sterile socket
#

Well, there's still an issue with how you're creating a vector

keen valve
#

add new

sterile socket
#

Yes.

keen valve
#

and you're saying i gotta put that in the state machine too?

sterile socket
#

And while you're at it, remove the line above that sets the velocity.

keen valve
#

so how's this?

#

and how will we change the velocity then?

#

oop

sterile socket
#

You need to change the return type of the UpdateState method and return whatever you're returning from the state update.

keen valve
keen valve
#

or make it something else?

sterile socket
#

It's return type should be that, yes.

keen valve
#

no but, like, that makes no sense

sterile socket
#

Well, what does the error say?

sterile socket
keen valve
#

not all code paths return a value

keen valve
sterile socket
sterile socket
keen valve
sterile socket
#

Yes. But for now you can return a zero Vector2 at the very bottom of the method.

sterile socket
#

No.

keen valve
#

and this also has to be in changestate or is that another thing?

#

but you just said

sterile socket
#

So we have the HorizontalMovement method, right? What did we just do to it?

keen valve
#

have it return a vector

sterile socket
#

Correct. And how do we access what it returns?

keen valve
#

so set velocity to HorizontalMovement()?

#

and then what do we return? velocity?

sterile socket
#

Try that - assign what HorizontalMovement returns to a variable.

keen valve
#

assign it to a vector2... then assign velocity to that vector2?

sterile socket
#

No

#

Ughhh... You really are missing the very basics... How do we assign a function result(it's return value) to something?

keen valve
#

i'm sorry

sterile socket
#

It's fine. I wish you did learn C# basics before moving on to unity project though...

keen valve
#

which is weird

#

because i was just learning about it too

sterile socket
keen valve
#

we are making no progress 🤣

sterile socket
#

Let's say we have 2 methods:
float A()
float B()
And you need the B value, but you can only access B in A. How do you get that value from somewhere you can access A?

orchid matrix
#

Arent you finishing a programming course?

#

game is tyour capstone right'

keen valve
sterile socket
keen valve
#

idk like say you have a method...

#

oh wait shit

#

no i'm thinking it wrong

#

so you have 2 methods A and B. you can only access B in A?

#

so floatA(B)?

#

idk maybe either i'm interpreting what you're saying wrong or you're not phrasing it right?

#

because i do NOT remember them teaching this to us

#

and this is years of college

sterile socket
#

Ok. Let's make it simpler. The facts is that you've already used it so many times.

#

When you do bool a = Input.GetKeyDown();
What's happening on that line?

keen valve
#

you're setting it to when you press down

sterile socket
#

What happens from the perspective of the program? What is GetKeyDown?

keen valve
#

a is true when you Input.GetKeyDown

#

a is true when you press down

#

that's not right, is it?

sterile socket
#

Why is a becoming true?

keen valve
#

because apparently five years of college means jack lol

keen valve
sterile socket
#

That doesn't answer the question

sterile socket
keen valve
#

maybe i just need to practice it more

#

but anyways this is so off topic do you remember what we're even doing?

#

trying to figure out what to put in the movement state

sterile socket
#

We're not going anywhere unless you can answer these simple questions

keen valve
#

ok

sterile socket
#

They're not off topic. They're absolutely necessary topics for you to complete your project.

keen valve
#

ok

#

so the question is why is a set to getkeydown?

sterile socket
keen valve
#

so getkeydown is the value

#

yes?

sterile socket
#

It's not a value.

keen valve
#

but it's a = input.getkeydown

sterile socket
#

Why does it have parenthesis?

#

GetKeyDown()

#

What does it tell us about it?

keen valve
sterile socket
#

No. Unrelated.

keen valve
#

fuck

sterile socket
#

Ok, let's go from the other side. What's a function/method in C#(or really any programming language)?

keen valve
#

a named set of actions

sterile socket
#

Nnn... Not wrong, but it's not exactly the correct definition.
But okay, syntax wise, how do you tell if something is a function?

keen valve
#

it has a paranthesis?

keen valve
sterile socket
#

Okay. That's better.

keen valve
#

so getkeydown is the function

sterile socket
#

Then going back to GetKeyDown() what is it?

keen valve
#

a function

sterile socket
#

Correct.

keen valve
#

so you are calling the function

sterile socket
#

Okay, good. We call it and then what happens?

keen valve
#

we set the key

sterile socket
#

No

keen valve
#

we don't?

sterile socket
#

Before that

keen valve
#

oh... huh?

sterile socket
#

What happens after we call it?

keen valve
#

what do you mean?

#

a = getkeydown()

sterile socket
#

Yes

#

What do we assign to a here?

keen valve
#

bool?

#

true?

sterile socket
#

Bool is the type of what we assign. But where does the value come from?

keen valve
#

the value comes from the input?

#

from getkeydown()

sterile socket
#

How does it come from it though?

keen valve
#

you...press the button?

#

or we... call the function?

sterile socket
#

What's probably happening on the other side?

keen valve
#

it's looking for what to return?

sterile socket
#

Okay

#

So in the end what does the function do?

keen valve
#

returns a value?

sterile socket
#

Correct

keen valve
#

so we have a variable that calls a function that returns a value

sterile socket
#

The variable doesn't call anything. Your code does.

keen valve
#

oh

#

the variable is set to the function

#

that returns a value

sterile socket
#

No

keen valve
#

i...

sterile socket
#

At least the wording is incorrect.

keen valve
#

the rules...

#

they keep changing

sterile socket
#

Let's pretend were the CPU that executes that code. What are the steps that we go through?

#

Assuming we just arrived on that line.

keen valve
#

we assign the value

sterile socket
#

No

#

What do we assign?

keen valve
#

i mean variable

sterile socket
#

How do we know what to assign?

keen valve
#

the type

sterile socket
#

What type? How do we know what value to assign?

keen valve
#

say no

keen valve
#

we call it a bool

sterile socket
#

What's bool?šŸ˜‚

keen valve
#

bool is the type

#

it's true or false

sterile socket
#

Okay, but what does it have to do with what we assign?

keen valve
#

jack

sterile socket
keen valve
#

this is, like, going into DEEEEEP

sterile socket
#

No. It's very shallow

keen valve
#

bool. its a type. returns true or false

#

that's what the professor said.

#

believed them all these years

#

apparently not true

sterile socket
#

Forget what the professor said. You're a CPU now. You execute the line. What steps are you going through?

keen valve
#

what's the type

#

yup not right, huh?

sterile socket
#

Is that a step..? What are you trying to say by that?

keen valve
sterile socket
#

Okay, let's assume so. What's next?

keen valve
#

not right, huh?

sterile socket
#

Not really. But it doesn't matter even if it was.

keen valve
#

at this point i'm running low on patience

sterile socket
#

Write down the steps that explain the execution of that line.

keen valve
#

i forgot what you even asked

#

how does a CPU execute a line of code?

#

oh do you mean fetch, decode, execute?

#

we give it the code. it decodes the line. then stores the code and runs it

sterile socket
#

That specific line of code

a = GetKeyDown(someKey);
keen valve
#

so we get the line of code

sterile socket
#

No. That's not what I'm asking. I'm asking about the program execution flow. Basically, what logically happens there.

keen valve
#

i'm about to cry

sterile socket
#

Ok, programming is too hard, leta go to math.

keen valve
#

no i want to keep going

#

i want to figure this out

#

i swear I know programming lol

sterile socket
#

You will, but it's necessary to understand it logically.
We have a formula x = a * y
What can we call the right side of the equation?

keen valve
#

the solution

sterile socket
#

No

#

A function

keen valve
#

okay

#

it's a function

sterile socket
#

How do we solve it step by step?

keen valve
#

we have one go to the left via division

#

so, like, if we wanna solve y, x/a = y

sterile socket
#

No. We want to find x. Let's say we know y and a.

keen valve
#

oh. then we multiply y and a

#

please tell me that's what you asked

sterile socket
#

Okay, so we basically do what with the function?

keen valve
#

we multiply it

sterile socket
#

No. In a general sense.

keen valve
#

we solve it

sterile socket
#

Correct.

#

Solve or execute it if we thing from the programming perspective.

#

And the what do we do with the x?

keen valve
#

we assign x to the solved function

#

i worded that wrong did i

sterile socket
#

We assign the result of executing the function to the left side, correct?

keen valve
#

yes

sterile socket
#

Ok. Now going back to our code line. We have a variable that we want to assign the results of the function on the right, correct?

keen valve
#

yes

sterile socket
#

The same thing as in math, right?

keen valve
#

yes

#

so cpu

sterile socket
#

So how would we solve it?

keen valve
#

we solve the right function

#

we solve getkeydown()

sterile socket
#

We execute it, yes.

keen valve
#

yes

sterile socket
#

And then

keen valve
#

then we assign the result to a

sterile socket
#

Correct.

keen valve
#

so a cpu:
-executes the function
-assigns the result to the variable

sterile socket
#

Yes.

keen valve
#

ok

#

so going back to your original, original question

sterile socket
#

How do we provide the result of the function from within the function?

keen valve
#

so we have a function, who is assigned another function

sterile socket
#

Function is not assigned. Remember the steps that the CPU does? What assigned is the result of the function execution.

keen valve
#

so the function is assigned the result of another function

sterile socket
#

Mind writing that in code? I'm trying to understand if you're misunderstanding or just using poor wording.

keen valve
#

so functio a = result of function b?

#

i guess i'm misunderstanding

#

function a returns the result of function b?

sterile socket
#

Step through that line as if you're a CPU.

keen valve
#

function a(){
return b()
}
function b(){
return answer
}

sterile socket
#

Okay, that's closer, but why are there parenthesis in the return line?

keen valve
#

better?

#

or remove those paranthesis too?

sterile socket
#

Yes

keen valve
#

yes remove the paranthesis?

sterile socket
#

No. That was correct

keen valve
#

oh okay

sterile socket
#

Ok, so this way you get the result of b from calling a.

keen valve
#

yes

sterile socket
#

Now going back to our state machine, we want the result of the current state to be returned by the state update function, right?

keen valve
#

yes

sterile socket
#

So how do we write it?

keen valve
#

return horizontalmovement()?

sterile socket
#

Correct

keen valve
#

then how do we set velocity?

sterile socket
#

At the bottom of the update function

keen valve
#

in default?

sterile socket
#

No. After the switch

keen valve
#

rgbd velocity = ?

#

the state you're in?

sterile socket
#

No. You'll need to save the state function result to a temporary variable and then assign it to velocity.

keen valve
#

where do i save it?

#

after switch?

#

or in the state?

sterile socket
#

There's only one place you an save it. Where you call the function.

keen valve
#

and this variable is a vector2 yes?

sterile socket
#

Yes

keen valve
sterile socket
#

No. What happens after return statement?

keen valve
#

you return the function

sterile socket
#

Exactly. That means that any code after that is not executed.

keen valve
#

put it before the return

sterile socket
#

No. There's a reason why we return the horizontal movement, right?

keen valve
#

yes

#

because it returns the horizontal movement

sterile socket
#

So that we get the result where?

keen valve
#

so put it in the method

#

the horizontal movement method

sterile socket
#

We return from this state update function to the Update, right?

keen valve
#

yes

sterile socket
#

And that's where we get the value from the specific state.

#

We can use that value then to assign to the velocity.

#

I guess it's a bit different from what we were trying to do at the beginning

keen valve
#

yeah

sterile socket
#

But anyways, that would do.

keen valve
sterile socket
#

Lost about what?

keen valve
#

so. the variable is assigned in Update?

#

and we assign it the result of UpdateState?

sterile socket
#

If you refer to rb velocity, then yes.

keen valve
#

ok.

#

so.

#

make a temporary variable in update

sterile socket
#

Maybe not ideal and it might be good to refactor it later, but let's keep it as is for now and test.

keen valve
#

well if it's not ideal, what should we do?

sterile socket
sterile socket
keen valve
#

okay. what exactly should we do?

sterile socket
#

Assign velocity

keen valve
#

in update or fixed update?

#

or does it matter?

sterile socket
#

Wherever we get the return value.

keen valve
#

so the state machine?

#

or switch statement i mean?

sterile socket
#

No. Where the state machine is being called from.

#

And it's not correct to call it "state machine" it's just a method that updates the current state.

keen valve
#

ok

#

so Update?

#

it's yes or no

sterile socket
#

If it's there, then yes.

keen valve
#

tbh, i don't think i even assigned it anywhere. my bad lol.

#

should assign it in update?

sterile socket
#

Assign what?

keen valve
#

the updatestate

#

i mean i didn't put it in update

#

I mean, do i put it in update?

sterile socket
#

Yes.

keen valve
#

and set rgbd.velocity to that right?

sterile socket
#

You want it to be updated every frame.

sterile socket
keen valve
#

so this?

sterile socket
#

Why would you call it twice?

keen valve
#

good point

#

so just this?

sterile socket
#

Yes

keen valve
#

okay let me send you the code i have so far

#

okay so basic movement works.
but can we assign it to horizontal movement at start?

sterile socket
#

The formatting is terrible, but it's ok for now.

keen valve
#

or is there something else wrong?

sterile socket
#

Why is it indented like that?

keen valve
#

idk

#

would ctrl+a help?

sterile socket
#

Donno. Your ide should format things automatically.

#

As you type.

keen valve
#

i'm looking at it and i guess not

#

anyways, is there a way i can assign horizontal movement from the start?