Player Speed

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);

}

}

At a guess I would say that it would be the rbody.MovePosition(). Multiply the content of it by however much you want to increase the speed by. For example here I am using a variable callet ‘moveSpeed’

  rbody.MovePosition (rbody.position + movement_vector * Time.deltaTime * moveSpeed);

At the start of your script (with Rigidbody2D rbody and Animator anim) put:

public float moveSpeed;

You will have to set the ‘moveSpeed’ in the inspector.

You can also set ‘moveSpeed’ through script should you need by setting it like so:

moveSpeed = 10f;

Hope this helps :slight_smile:

Thank you so much dude! I wish you all the best!