#Some movement thing
1 messages Ā· Page 1 of 1 (latest)
@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
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
I mean up to you, Iām still fairly surprised that he has done an exam already if he hasnāt taught anything :/
could i even call you ? and screen share ?
Youāll need a rigidbody on your paddle and disable gravity on it
Sorry Iām in a busy spot
yeah thought it was a long shot
Do this first
ill show you the code he gave us tho
Sure
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
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
For input (a and d button presses)
https://docs.unity3d.com/ScriptReference/Input.GetKeyDown.html
Do you know how to use that?
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
I mean my teacher mostly expects us to Google anything that I donāt understand so maybe yours is doing the same
Look at the example
In the docs
i understand it by itself
Does it make sense or should I explain it
i dont get the void update monbehaviour but i understand the gist of it
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
It runs every frame
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
do i right the { //some code } ?
Do you know what the // is?
no
Really?
yes
// comment and /* comment */ are comment syntax
oh but he hasn't
What has he taught you?
nothing literally i think he's getting fired soon but i still to pass the exams
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
But anyways do you know how to format an if statement
yes
i know how to explain the if in spoken language but not in code
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
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
Well yes, but letās focus on left movement for now
Right now you can detect the button A. Whatās the next step
ummm
You might be a bit confused:
When the player presses A, what do you want the game to do?
i would like for the avatar to be moving to the right
Alright, we are going to move it through Rigidbody2D
so we are moving the avatar thanks to rigidbody ?
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
#854851968446365696 last embed
it's in french so im trying to translate
Thatās fine
Delete the Debug.Log
done
Also move the if statement under the TODO
done
Run it again
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
If statements have 2 {}
.
Tbh I really donāt have to explain all these things :/
i feel so dumb rn
Ok what have you done so far
Ok thatās good so far
Now we need the {
After the if statement
if ()
{
// do you see what you are missing?
}
i m looking into it rn
i dont see which one is missing
i have found some ) missing tho
i have added those
Yes I missed that but you are missing a {
it worked it worked it worked !!!!!
Ok is the code working now
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
has not worked for D
Screenshot it
Move the if statement under the other if statement
Looks like he meant for us to use input axis horizontal but thatās not important they basically do the same thing
Tell me when you moved it
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
i have done it
Does the code work
Delete the āās
Undo it
You deleted too much
ctrl z and look at what I āād out
Delete anything inside the red
Ok letās move Input D under Input A
Weāre back to this step:
https://cdn.discordapp.com/attachments/928450849968099419/928468526686154803/IMG_2572.png
like so ?
undone
Try again
line 71 the word public does not work
i will try
Ignore the red line
Let me know when youāve done it. Thereās something else you have to do afterwards
ok
Basically put a } at where the blue dot is on the picture
i have done it
Screenshot so far
Ok make sure you do this next step correctly
yes
surgical precision
Show me a screenshot when you are done
i thought i did
You need to move the input code outside the GameManager if Statement but keep it inside the FixedUpdate
Yes and move it under the next }
error line 130
Can you show the line
Youāre probably missing a } somewhere if I had to guess or deleted a { somewhere
is there a way to know where
Well normally youād look at the code to know where but I canāt see it
Delete the } without the dotted line
That might fix it
In the first image
A and D make it move to the left
it it works
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
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 !!!
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
i actually had a row with him in class because i asked to many questions to which he would not answer
Thereās probably some tutorials online that you could try watching to figure something out