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.

29 lines
659 B

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