So, I have looked over the internet for a bit now, yet everything I try doesn’t work. I put a movement script I have from a platformer onto the player, but I can only move it left and right. I am gonna post my code below, but my question is how to make it move up and down? Thanks for any help!
using UnityEngine;
using System.Collections;
public class MoveTopDown : MonoBehaviour {
public float speed =1.0f;
public string axisName = "Horizontal";
// Use this for initialization
void Start () {
}
void Update ()
{
}
// Update is called once per frame
void FixedUpdate () {
if (Input.GetAxis (axisName) > 0)
{
Vector3 newScale = transform.localScale;
newScale.y = 1.0f;
newScale.x = 1.0f;
transform.localScale = newScale;
}
else if (Input.GetAxis (axisName) < 0)
{
Vector3 newScale =transform.localScale;
newScale.x = 1.0f;
transform.localScale = newScale;
}
transform.position += transform.right * Input.GetAxis (axisName) * speed * Time.deltaTime;
}
}