fork download
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class FPSInput : MonoBehaviour
  6. {
  7. public float speed = 6.0f;
  8. public const float baseSpeed = 6.0f;
  9. public float gravity = -9.6f;
  10.  
  11. private CharacterController _charController;
  12.  
  13. void Awake()
  14. {
  15. Messenger<float>.AddListener(GameEvent.SPEED_CHANGED, OnSpeedChanged);
  16. }
  17.  
  18. void OnDestroy()
  19. {
  20. Messenger<float>.RemoveListener(GameEvent.SPEED_CHANGED, OnSpeedChanged);
  21. }
  22.  
  23. private void OnSpeedChanged(float value)
  24. {
  25. speed = baseSpeed * value;
  26. }
  27.  
  28. // Use this for initialization
  29. void Start ()
  30. {
  31. _charController = GetComponent<CharacterController>();
  32. }
  33.  
  34. // Update is called once per frame
  35. void Update ()
  36. {
  37. float deltaX = Input.GetAxis("Horizontal") * speed;
  38. float deltaZ = Input.GetAxis("Vertical") * speed;
  39.  
  40. Vector3 movement = new Vector3(deltaX, 0, deltaZ);
  41. movement = Vector3.ClampMagnitude(movement, speed);
  42.  
  43. //movement = movement * Time.deltaTime;
  44.  
  45. movement = transform.TransformDirection(movement);
  46. _charController.Move(movement);
  47. movement.y = gravity;
  48.  
  49. /*transform.Translate(deltaX * Time.deltaTime, 0, deltaZ * Time.deltaTime);
  50.  
  51.   /*Debug.Log(deltaX);
  52.   Debug.Log(deltaZ);
  53.   Debug.Log(Time.deltaTime);*/
  54. }
  55. }
  56.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(3,7): error CS0246: The type or namespace name `UnityEngine' could not be found. Are you missing an assembly reference?
prog.cs(5,25): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?
prog.cs(11,13): error CS0246: The type or namespace name `CharacterController' could not be found. Are you missing an assembly reference?
Compilation failed: 3 error(s), 0 warnings
stdout
Standard output is empty