I am trying to create a character controller for a 2d platformer (I mean without a rigidbody). I have looked online but could not find any good tutorials. Does anyone know where a good tutorial for this is? Or is it better to just try to find things that are related to it, and piece information together? And if so, can I get some pointers on where to start? Thanks.
I have exactly such a thing here: 2D Animation Methods in Unity. Be sure to download the demo project, since Gamasutra mangles the code a bit.
Where is the example project?
Oh nevermind I found it
How would one implement collisions and walls into this?
Will I show a C# script for 2D character controller?
What?
Will I show the script?
Say yes if you want.
Yes
And, it will be with a rigidbody2D
And to move you need to use WAD.
W to jump, A to move left, D to move right
using UnityEngine;
public class Player : MonoBehaviour
{
Rigidbody2D Rig2D;
public float Speed = 5f;
public float JumpForce;
void Start()
{
Rig2D = GetComponent<Rigidbody2D>();
}
void FixedUpdate()
{
if (Input.GetKey(KeyCode.A))
{
transform.position -= transform.right * Speed *
Time.deltaTime;
}
if (Input.GetKey(KeyCode.D))
{
transform.position += transform.right * Speed *
Time.deltaTime;
}
}
private void OnCollisionStay2D(Collision2D Collision2D)
{
if (Input.GetKeyDown(KeyCode.W))
{
Rig2D.AddForce(new Vector2(0, JumpForce * 50));
}
}
}
sorry, still quite Buggy…
Please name your script “Player”
Hmmm not quite what Im looking for
And what do you want?
What game do you want to make?
Do you make your terrain with tilemap?
Oh, yes, there is a bug, you can clim up the wall.
A controller that doesnt use rigidbody mainly because it has difficulty handling slopes and isnt quite as easy to fine tune as a character controller
No rigidbody?!
Yes… a character controller that functions without a rigidbody