You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

30 lines
742 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterMovement : MonoBehaviour {
public float Speed;
public GameObject localPlayer;
//Public movement functions :)
public void MoveLeft()
{
localPlayer.GetComponent<Rigidbody>().AddForce(new Vector3(-Speed, 0.0f, 0.0f));
}
public void MoveRight()
{
localPlayer.GetComponent<Rigidbody>().AddForce(new Vector3(Speed, 0.0f, 0.0f));
}
public void MoveUp()
{
localPlayer.GetComponent<Rigidbody>().AddForce(new Vector3(0.0f, 0.0f, Speed));
}
public void MoveDown()
{
localPlayer.GetComponent<Rigidbody>().AddForce(new Vector3(0.0f, 0.0f, -Speed));
}
}