Hello!
I’ve been googling around about this question for a while and I can’t really find a very good answer to it.
I have as my School-project to make a game. and we decided to make a 2D platforming/puzzle game.
We do have some ideas and the first problem we have now is the movement.
I’ve tried out Langman movement (the “upgrade” to the 2D tutorial movement). I like the Langman-script for the movement, but it’s too advanced for my skills in Javascript.
Atleast I want to understand every single thing in the script, how it works.
I want to create my own script, atleast in my level, just something easy with movement and jump, and everything in here should be smooth, the character should also look like he turns around…
Hopefully I’ll get a good answer on a simple code or just a small tutorial about how to understand how to create my own movement-script.
Bear in mind I’m a total newbie in this, so don’t be that advanced in your talking about scripting, or using things in Unity3D. Not much is very simple for me yet^^
Thanks in advance!
// Exlerth
so you have never programmed before or?
well you will need to learn the basics like variables and such.
just an very simple script.
//here we delcare the variables
//make a new variable and its a float so it have decimals/ we have more control of how fast we want the player to move
var moveSpeed : float = 10F;
//we use the update function with is going to be used every frame.
function Update(){
tranform.Translate(Input.GetAxis("Horizontal") * moveSpeed * Time.deltatime,0,0);
//okay here we make the player move
//okay lets see what this does
//transform (gets the transform of the object/player x,y,z) then we use Translate with is a premade function for the unity engine,
// okay so its saying Translate(x,y,z) so what we are doing is using the Input.GetAxis("Horizontal") where the x is in the translate function.
//the Input is gonna return us 1,0,-1 if the key is being pressed or not. we * that with our moveSpeed f.eks if we hit D its gonna return us 1 and we times //that with moveSpeed then we * it with Time.deltatime with is gonna do that its the same for all no matter if you have a slow or fast computer
// because remember we use the Update fucntion wich is gonna update every frame so that means it will go faster if you got a fast computer than a slow
}
Asii, that has to be the most perfect base script I’ve ever seen. I’ve too been meandering aimlessly trying to find a script for movement that is strictly barebones. I’m a software engineer by profession, however I’ve never done 2D or 3D programming, so I’m at a loss when it comes to finding the basics. Kudos, my man.