Topdown 2D Colliders Not Working, help!
Righty, so I'm doing a 2D top down RPG thing and I want to get the basics done (speed, movement, map design working, etc.) and I decided to give the colliders a try. Unfortunately they are not working at all, and it's really irritating.
I know it's due to my character controller, and I have toyed with the "true" and "false" settings on the first two, but it's only lead to these results.
TT: https://gyazo.com/48a504a3173de69b82a2c0619124c8b8 FF: https://gyazo.com/f8d1da85f6236a79f12bc43109563983 FT: https://gyazo.com/c7f2c1952ef2e879f2be56720fa9dc93 TF: https://gyazo.com/26beb0d5a1b90c02c43393a24dc4fce8
What am I not understanding or missing here?
Character Controller:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
private Vector2 pos;
private bool moving = true;
public float speed;
void Start () {
pos = transform.position;
}
void Update () {
CheckInput ();
if (moving) {
transform.position = pos;
moving = false;
}
}
private void CheckInput() {
if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow)) {
pos += Vector2.right * speed;
moving = true;
}
if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) {
pos -= Vector2.right * speed;
moving = true;
}
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow)) {
pos += Vector2.up * speed;
moving = true;
}
if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow)) {
pos -= Vector2.up * speed;
moving = true;
}
}
}
I think you need to add a Rigidbody2d on your player and freeze the x and y rotation.
Your answer
Follow this Question
Related Questions
Is it possible to control prevent/enable colisions based on the value of a variable. 2 Answers
How do you add a Collider2D to a Line Renderer In Unity2D? 0 Answers
Destorying objects on collsion 1 Answer
Can't seem to get collision to work among my sprites 1 Answer
Storing variable collisions and editing variables in other files (2d) 0 Answers