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.

36 lines
845 B

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