So, I’ve been watching this Unity tutorial by rm2kdev, making an RPG. I finally got to the point where I had to code the player script. I copied his code exactly, and I got it to work, but there was one problem, the character was pretty slow, and since I’m new to coding, I had no idea on how to increase the players speed. If any of you can help me, that would be great! Here is the code I’m using :
using UnityEngine;
using System.Collections;
public class PlayerMovement : MonoBehaviour {
Rigidbody2D rbody;
Animator anim;
// Use this for initialization
void Start () {
rbody = GetComponent<Rigidbody2D> ();
anim = GetComponent<Animator> ();
}
// Update is called once per frame
void Update () {
Vector2 movement_vector = new Vector2 (Input.GetAxisRaw ("Horizontal"), Input.GetAxisRaw ("Vertical"));
if ( movement_vector != Vector2.zero )
{
anim.SetBool("iswalking", true);
anim.SetFloat("input_x", movement_vector.x);
anim.SetFloat("input_y", movement_vector.y);
}
else
{
anim.SetBool("iswalking", false);
}
rbody.MovePosition (rbody.position + movement_vector * Time.deltaTime);
}
}