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

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CharacterMovement : MonoBehaviour {
  5. public float Speed;
  6. public GameObject localPlayer;
  7. //Public movement functions :)
  8. public void MoveLeft()
  9. {
  10. localPlayer.GetComponent<Rigidbody>().AddForce(new Vector3(-Speed, 0.0f, 0.0f));
  11. }
  12. public void MoveRight()
  13. {
  14. localPlayer.GetComponent<Rigidbody>().AddForce(new Vector3(Speed, 0.0f, 0.0f));
  15. }
  16. public void MoveUp()
  17. {
  18. localPlayer.GetComponent<Rigidbody>().AddForce(new Vector3(0.0f, 0.0f, Speed));
  19. }
  20. public void MoveDown()
  21. {
  22. localPlayer.GetComponent<Rigidbody>().AddForce(new Vector3(0.0f, 0.0f, -Speed));
  23. }
  24. }