Left and right movment are slower than up and down.
I have a problem. My caracter movement are slower when it left and right compare do up and down. I do not understand Because its the same code but with diffeerent valu in a vector2. My game is in 2d and my problem started when I started to use custom animation.
Movement Up
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class up : MonoBehaviour {
public float maxSpeed = 10f;
private Rigidbody2D rb2d;
Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
rb2d = GetComponent<Rigidbody2D>();
rb2d.velocity=Vector2.zero;
}
// Update is called once per frame
void FixedUpdate() {
anim.SetInteger("State", 2);
Vector2 movement = new Vector2(0f, 1f);
rb2d.AddForce(movement * maxSpeed);
}
}
Movement Left
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Left : MonoBehaviour {
public float maxSpeed = 10f;
private Rigidbody2D rb2d;
Animator anim;
void Start () {
anim = GetComponent<Animator>();
rb2d = GetComponent<Rigidbody2D>();
rb2d.velocity=Vector2.zero;
}
// Update is called once per frame
void FixedUpdate () {
anim.SetInteger("State", 1);
Vector2 movement = new Vector2(-1f, 0f);
rb2d.AddForce(movement * maxSpeed);
}
}
Comment