So i am new to game development speceficly 3d games and i wonder why this code for the character to move isnt working any ideas or better code would be appreciated
Not downloaded yet
About this post
- Posted
- Archived
- Score
- 2 · 58% up
- Kind
- Image
- ID
- rr67pm
25 comments
https://www.take-a-screenshot.org
You have to learn it anyway when you want to promote your game, so you can just as well start now.
Its my brothers laptop not mine i am not that stupid
The V in vertical needs to be capitalised.
Input.GetAxis(“Vertical”);Also make sure you’ve attached the script to an object, like the player, or it won’t work.
To get an obvious question out of the way: did you attach the script to the object.
It must be attatched to something for it to even start.
I mean i am stupid just not that stupid
Nobody assumes you are stupid. Just that you are uninformed. Which is nothing to be ashamed of.
Just writing scripts and assuming they will do stuff on their own is not a completely absurd assumption to make. Especially considering that this is exactly how Systems work in the new DOTS stack (no, don't look that up yet).
Alright. Now let's talk about the transform. I would try typing 'this' which targets the script. Also doing 'this.gameObject' targets the object that the script is attached to. So it would be something like:
this.gameObject.transform.position
Remove the faulty semi colon on your last line. Also currently your speed value of 0.1 f means that per update you move that amount.
You should add a „ * Time.DeltaTime „ and normalize your moveDirection as currently you d move faster diagonally. (The magnitude of your vector would be higher then 1)
Also make sure that your monobehaviour is attached to your game object.
Additionally, you could cache your transform on top of your class but I think you don’t have to do that anymore as unity does it somewhat automatically for performance increase. (Isn’t extremely significant for one instance.
Also, write your Script names with uppercase letters. ( just a Convention, not Beck Breaking if you don’t)
Ex. Move PlayerManager GameManager ObjectMovesCircular
I just can't look at that keyboard. It should be on r/dontflinch
Well its my brothers sooo
Then you're good.
Yeah, collective of what everyone else said: -Get rid of that extra semicolon at transform.position += moveDirection*speed;
-Capitalize the word "Vertical" or it won't take that directional input at all
I'm not too sure on what next without seeing it, but those 2 are the biggest points to correct.
Let us know!
I'm not too familiar with the environment, but is that a rogue semi colon on the last line of before the "*"?
You are right it was an error but the model still wont move for some reason
I think you also need to normalise your move direction vector, but that wouldn't explain why there's no movement at all.
Sorry, I dont know Unity so don't think I can be of much more help.
Looks like it, and that also would show an error with exactly what the problem is..
I can’t answer your question but I just wanted to ask how you’re learning? I’m thinking of doing a game dev course in trade school soon :)
The untiy coarses they are free :)
Sweet! Are you thinking of using unreal engine too?
If I'm seeing the red error message at the borrom left of your screen right, I'm guessing it's not compiling.
Yea another guy saw the problem, but the real problem is that the model isnt moving
You need to fix the compiling problem first. When a script which doesn't then it can not do anything.