i wanna make a 2d platformer and i need some help with the character controller
I’ve also been looking for one, I cant seem to find one yet.
you’ll want something like this if you are using rigidbodies
public float moveSpeed;
void FixedUpdate(){
if(input.getkey(keycode.A){
GetComponent<Rigidbody2D>.velocity = new vector2 (-moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
//to flip sprite
transform.localscale = new Vector3(-1,1,1);
}
if(input.getkey(keycode.D){
GetComponent<Rigidbody2D>.velocity = new vector2 (moveSpeed, GetComponent<Rigidbody2D>().velocity.y);
//to flip sprite
transform.localscale = new Vector3(1,1,1);
}
}
for jumping you’ll want to set a jumpHeight float and change your x velocity according to your jumpHeight.
ty dreyescairo
That still doesnt work for me… i have tried like 4 scripts, and the *game still wont run.
Check this one: GitHub - prime31/CharacterController2D
Also check the 3DBuzz free tutorial on youtube.