R2d.velocity = new Vector2((moveDirection) * maxSpeed, ) ĭebug.DrawLine(groundCheckPos, groundCheckPos - new Vector3(0, colliderRadius, 0), isGrounded ? een : Color.red) ĭebug.DrawLine(groundCheckPos, groundCheckPos - new Vector3(colliderRadius, 0, 0), isGrounded ? een : Color. T.localScale = new Vector3(Mathf.Abs(t.localScale.x), t.localScale.y, ) įor (int i = 0 i < colliders.Length i++) MoveDirection = Input.GetKey(Ke圜ode.A) ? -1 : 1 R2d.collisionDetectionMode = CollisionDetectionMode2D.Continuous ĬameraPos = I dont want anything fancy, just being able to jump and run through the level made of meshes (with slopes), without worries of falling through stuff, or getting stuck anywhere. Public class CharacterController2D : MonoBehaviour A simple 3D Platformer game made on Unity using LeoECS lite. Hi, I want to create a small 3d platformer, Mario-64 style, but Im not sure of what to use for the actual player movement. Create a new script, name it "CharacterController2D" and paste the code below inside it:ĬharacterController2D.cs using System.Collections.Assign your sprite to "player_sprite" and move it inside the "Player" Object.Create another GameObject, call it "player_sprite" and add the Sprite Renderer component to it.Create a new GameObject and call it "Player".Im using a character controller because the movement is much more precise.
![unity 3d platformer character controller unity 3d platformer character controller](https://i.ytimg.com/vi/XUuuwBTfMAM/maxresdefault.jpg)
Id rather not use rigidbodies for my character, they are too unpredictable.
![unity 3d platformer character controller unity 3d platformer character controller](https://i.ytimg.com/vi/JK2lKgh4JSc/maxresdefault.jpg)
Open Scene with your 2D level (make sure the level sprites have 2D colliders attached, so the player won't fall through) If you want momentum, you could handle the jump by using Add Force on a Rigidbody object.The controller will be physics-based and will use a Rigidbody2D component. To make a 2D Platformer Character Controller in Unity, follow the steps below. 2D Platformer is a type of game where the player jumps between platforms, avoids obstacles, and fights enemies, all of which is observed from a 2D side-view perspective.