So I’m making a very simple “game” where all you need to do is get to the flag.
I have the entire map setup in 1 photoshop image, with 2D Box Colliders mapped on all the edges of the map.
Basically whenever I fall off the ledge, A; the box/player rotates. I want him to always be upright. and B; When the player does rotate, the transform is obviously being determined locally and forces it to move wherever it’s facing side is angled at. Can anyone help?
Heres my code.
using UnityEngine;
using System.Collections;
public class Movement : MonoBehaviour
{
public float speed = 5.0f;
public float jumpHeight = 2.0f;
public bool isDead;
void Start ()
{
}
void Update ()
{
if (Input.GetKey (KeyCode.LeftArrow))
{
transform.position -= transform.right * speed * Time.deltaTime;
}
else if (Input.GetKey (KeyCode.RightArrow))
{
transform.position += transform.right * speed * Time.deltaTime;
}
}
}