Help for Isometric 4-direction Player Movement?
So I'm attempting to make a character move in 4 (or 8, with combined keypresses) directions on a flat 2D background, and I found a tutorial which seemed to be a solution, but it turns out that even though their sample game clip moves in all directions on a flat plane, it doesn't work that way on mine. In my game, my character moves just fine left and right, but I can't move up or down or diagonally. I tried replacing the 0 in the Vector3 to include a third axis, but that didn't work. This script works perfectly beyond not being able to move up, so how do I add movement up and down? I know 2D characters can move up, because in platformers you can jump...
I'm using this setup on the inspector:
This is my prototype scene:
I'm using this script as my base:
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour
{
public float speed = 6.0F;
private Vector3 moveDirection = Vector3.zero;
public CharacterController controller;
void Start()
{
// Store reference to attached component
controller = GetComponent<CharacterController>();
}
void Update()
{
// Use input up and down for direction, multiplied by speed
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
// Move Character Controller
controller.Move(moveDirection * Time.deltaTime);
}
}
I've made simple games before in other engines, but this is driving me nuts! My research for this engine said to use Input.GetAxis instead of getting a particular key pressed, to avoid issues with people using a controller versus a keyboard and mouse. I'm mainly familiar with setting all possible keys and buttons for a specific action required and then calling the action for use with any linked input, but apparently Unity doesn't work this way? I've researched this for hours and have not found a script solution for this, please help.
you are moving in the z axis when i imagine you are trying to move in the y axis.
moveDirection = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
Your answer
Follow this Question
Related Questions
What is a good way to have my player grab and roll a boulder like in Tomb Raider isometric games 0 Answers
How can I display text over a sprite in isometric perspective?,Text on isometric tile 0 Answers
Help! My third person character needs and exorcist! 1 Answer
Why doesn't my character move? 0 Answers
How to make the character roll and also resize the collider? 0 Answers