#Some movement thing

1 messages Ā· Page 1 of 1 (latest)

polar maple
#

@drowsy jolt anyways what do you so far know how to do? I find it pretty unlikely that the teacher has given you an exam and hasn’t taught simple movement/input yet

drowsy jolt
#

if i could show how bad he is at teaching i would

#

he does not mind going through a heavy amount of code without a shred of explanation

#

hey listen is there any way i could show you the code he gave us ? i m very desperate

polar maple
#

I mean up to you, I’m still fairly surprised that he has done an exam already if he hasn’t taught anything :/

drowsy jolt
#

could i even call you ? and screen share ?

polar maple
#

You’ll need a rigidbody on your paddle and disable gravity on it

polar maple
drowsy jolt
#

yeah thought it was a long shot

drowsy jolt
#

ill show you the code he gave us tho

polar maple
#

Sure

drowsy jolt
#

i tried to paste it

polar maple
#

Well he’s given you a lot of ToDos

#

First you need to get input working

#

Search up how to get the keys of A and D

drowsy jolt
#

i have but i dont understand when i put them they never work

#

i looked up code but i dont understand visual keeps telling me that stuff is not being used or other things i dont understand

polar maple
#

Do you know how to use that?

drowsy jolt
#

no clue i found this earlier i pasted it and something went wrong

#

i tried to understand but im just stuck because of concepts i dont understand yet

polar maple
#

I mean my teacher mostly expects us to Google anything that I don’t understand so maybe yours is doing the same

polar maple
#

In the docs

drowsy jolt
#

i understand it by itself

polar maple
#

Does it make sense or should I explain it

drowsy jolt
#

i dont get the void update monbehaviour but i understand the gist of it

polar maple
#

Ok there’s another variation of GetKeyDown called GetKey. The difference is that GetKeyDown only runs once while GetKey will always run as long as it’s held down. We will be using GetKey

polar maple
#

Basically

#

Put if(Input.GetKey(KeyCode.A) { //some code } under the first TODO

#

Anything inside that if statement will run

#

As long as A is held down

drowsy jolt
#

do i right the { //some code } ?

polar maple
drowsy jolt
#

no

polar maple
#

Really?

drowsy jolt
#

yes

polar maple
#

…

#

I feel like the teacher would’ve explained that

dapper kite
#

// comment and /* comment */ are comment syntax

drowsy jolt
#

oh but he hasn't

polar maple
#

What has he taught you?

drowsy jolt
#

nothing literally i think he's getting fired soon but i still to pass the exams

polar maple
#

Exams are something that would happen at minimum a week or 2 after the class first begins. Also c# is something that the teacher probably expects for you to learn on your free time

polar maple
drowsy jolt
#

yes

polar maple
#

Ok show me

#

I’m on my phone so I can only send one line ones

drowsy jolt
#

i know how to explain the if in spoken language but not in code

polar maple
#

How did your teacher expect you to learn c#

#

On your own or in class

drowsy jolt
#

i ll try and give you the big picture im in a game design school and i have two seperate teachers one that teaches unity specificaly and one that teaches algorithm all the things i learn has been taught to me in algorithm however the unity teacher does not care if we understand or not he just goes on with his lesson as if anyone was understanding a thing he said

polar maple
#

Anyways:

if (Input.GetKey(KeyCode.A)
{
// insert your rb movement code
Debug.Log(ā€œRunning codeā€);
}

#

If you put that in FixedUpdate or update then it’ll print ā€œRunning codeā€ as long as you hold down A

#

@drowsy jolt does that make sense?

#

What do you think you’d put inside. You are now detecting the button press A. What do you think the next step is

drowsy jolt
#

im thinking

#

do the same with the left ?

polar maple
#

Well yes, but let’s focus on left movement for now

polar maple
drowsy jolt
#

ummm

polar maple
#

You might be a bit confused:
When the player presses A, what do you want the game to do?

drowsy jolt
#

i would like for the avatar to be moving to the right

polar maple
#

Alright, we are going to move it through Rigidbody2D

drowsy jolt
#

so we are moving the avatar thanks to rigidbody ?

polar maple
#

Yes

#

paddle.velocity = new Vector2(-1,0);

Will move the object to the left if you put it in the if statement. Do you have any questions on it?

#

No inside the if statement

#

We only want that code to run when A is being pressed

drowsy jolt
#

wait let my try again

#

when i type it in chat it vanishes

polar maple
drowsy jolt
#

my bad

#

so I type the paddle velocity inside of the {

polar maple
#

Yes

#

Try the code does it work?

drowsy jolt
#

im trying now

#

it says that running cod e has no context ?

polar maple
#

Send a screenshot

#

There’s a million reasons why that could happen

drowsy jolt
#

it's in french so im trying to translate

polar maple
#

That’s fine

drowsy jolt
polar maple
drowsy jolt
#

done

polar maple
drowsy jolt
#

done

polar maple
#

Run it again

drowsy jolt
#

wait no i must ve made a mistake

#

what statment am i getting rid off ?

#

i got rid of something and it went all redish

#

i misread

polar maple
drowsy jolt
#

ohhh

polar maple
#

You missed the {}

#

And delete (ā€œRunning codeā€);

drowsy jolt
polar maple
#

If statements have 2 {}

polar maple
#

Tbh I really don’t have to explain all these things :/

drowsy jolt
#

i feel so dumb rn

polar maple
#

Ok what have you done so far

drowsy jolt
polar maple
#

Ok that’s good so far

#

Now we need the {

#

After the if statement

#
if ()
{
// do you see what you are missing?
}
drowsy jolt
#

i m looking into it rn

#

i dont see which one is missing

#

i have found some ) missing tho

#

i have added those

polar maple
#

Do you see what you are missing

polar maple
drowsy jolt
#

it worked it worked it worked !!!!!

polar maple
#

Ok is the code working now

drowsy jolt
#

i pressed a and it move left

#

moved

polar maple
#

Ok good

#

Now copy the whole if statement

#

And paste a new one directly under it

#

All you should need to do is change A to D and -1 to 1

drowsy jolt
#

has not worked for D

polar maple
#

Screenshot it

drowsy jolt
polar maple
polar maple
# drowsy jolt

Looks like he meant for us to use input axis horizontal but that’s not important they basically do the same thing

polar maple
drowsy jolt
#

i dont understand where to move it

#

isnt it already below

polar maple
#

Also the blue dot šŸ”µ , you are missing a {

#

if statements run anything inside them. Since Input D is only inside Input A it’ll only run when A is being held down which is counter productive

#

You need it on the outside

#

Tell me when you’ve done it

drowsy jolt
#

i have done it

polar maple
#

Does the code work

drowsy jolt
polar maple
#

Delete the āŒā€™s

drowsy jolt
polar maple
#

Undo it

#

You deleted too much

#

ctrl z and look at what I āŒā€™d out

#

Delete anything inside the red

drowsy jolt
#

I dont know what i have done

polar maple
#

Ok let’s move Input D under Input A

drowsy jolt
#

like so ?

drowsy jolt
#

undone

polar maple
#

Try again

drowsy jolt
polar maple
#

Perfect

#

Now put a { where the blue dot is

#

The šŸ”µ

drowsy jolt
polar maple
#

Ok try the code

#

Does it work

drowsy jolt
#

line 71 the word public does not work

polar maple
#

Wait see the issue

drowsy jolt
polar maple
#

BRB

#

Close your fixed update

drowsy jolt
#

i will try

polar maple
#

Ignore the red line

#

Let me know when you’ve done it. There’s something else you have to do afterwards

drowsy jolt
#

ok

polar maple
# polar maple

Basically put a } at where the blue dot is on the picture

drowsy jolt
#

i have done it

polar maple
#

Screenshot so far

drowsy jolt
polar maple
#

Ok make sure you do this next step correctly

drowsy jolt
#

yes

polar maple
#

Delete the red

#

Also I want you to move the blue to that new spot

drowsy jolt
#

surgical precision

polar maple
#

Show me a screenshot when you are done

drowsy jolt
#

yes

#

pls tell me i did it

polar maple
#

You got the red deleted

#

Now move the blue

drowsy jolt
#

i thought i did

polar maple
#

You need to move the input code outside the GameManager if Statement but keep it inside the FixedUpdate

drowsy jolt
polar maple
#

Yes and move it under the next }

drowsy jolt
polar maple
#

Good

#

Try running the code

drowsy jolt
#

error line 130

polar maple
#

Can you show the line

drowsy jolt
polar maple
#

You’re probably missing a } somewhere if I had to guess or deleted a { somewhere

drowsy jolt
#

is there a way to know where

polar maple
#

Well normally you’d look at the code to know where but I can’t see it

drowsy jolt
polar maple
#

That might fix it

#

In the first image

drowsy jolt
#

A and D make it move to the left

polar maple
#

Second image

drowsy jolt
#

it it works

polar maple
#

I can’t help anymore

/* @TODO: give an angle to the ball. For example depending on distance to center (or alike)... */

I have no idea how to do that, as much as I might seem to be experienced with unity, I’m still a student

#

You could maybe try researching other ways or ask your teacher via email but I wouldn’t know where to start

drowsy jolt
#

dude i dont expect you to help me any more than you already have i am extremely thankful for your help honestly thank you thank you thank you !!!

polar maple
#

Yeah, maybe try asking your teacher if you can. He’ll probably help you out

#

Or you could try searching for a way online if you feel uncomfortable with that but I’d have no idea what to search

drowsy jolt
#

i actually had a row with him in class because i asked to many questions to which he would not answer

polar maple
#

There’s probably some tutorials online that you could try watching to figure something out