-
Put
direction = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"))
inUpdate
method then check it in theFixedUpdate
method. -
Use velocity to move right and left, and use force to make the jump.
-
To make the jump, you have to check if the character is on the ground by creating an empty object and attach it to the character, then check if the empty object is colliding with the ground.
-
Of course you have to define what is ground, by making a new layer and put all objects that are supposed to be ground in it and choose this layer as ground.
-
Check freeze rotation because if you don't, you will lose control of your character, trust me (Rigidbody2D -> constrains -> Freeze Rotation -> Z).
-
Create physics material with zero friction then, assign it to the character to avoid sticking to the wall.
-
Don't use Box Collider for the character use any collider with a rounded shape.
-
Notifications
You must be signed in to change notification settings - Fork 0
KhaledR57/UnityCharacterMovement
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
C# script for Unity 2D character movement