fork download
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5.  
  6. public class OguraToosutoController : MonoBehaviour
  7. {
  8. Rigidbody2D rigid2D;
  9. float jumpForce = 600.0f;
  10. float walkForce = 60.0f;
  11. float maxWalkSpeed = 6.0f;
  12.  
  13. void Start()
  14. {
  15. this.rigid2D = GetComponent<Rigidbody2D>();
  16. }
  17.  
  18. void Update()
  19. {
  20. //移動
  21. int key = 0;
  22. if(Input.GetKey(KeyCode.RightArrow)) key = 1;
  23. if(Input.GetKey(KeyCode.LeftArrow)) key = -1;
  24.  
  25. float speedx = Mathf.Abs(this.rigid2D.velocity.x);
  26.  
  27. if(speedx < this.maxWalkSpeed)
  28. {
  29. this.rigid2D.AddForce(transform.right * key * this.walkForce);
  30. }
  31. //ジャンプ
  32.      Vector2 pos = new Vector2(-10.0f, -3.139f);
  33. Vector2 direction = new Vector2(1.0f, 0.0f);
  34. float maxDistance = 20.0f;
  35. RaycastHit2D hitInfo;
  36.  
  37. hitInfo = Physics2D.Raycast(pos, direction, maxDistance);
  38. if(hitInfo.collider != null && Input.GetKeyDown(KeyCode.Space))
  39. {
  40. this.rigid2D.AddForce(transform.up * this.jumpForce);
  41. }
  42. }
  43. }
  44.  
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(6,39): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?
prog.cs(8,5): error CS0246: The type or namespace name `Rigidbody2D' could not be found. Are you missing an assembly reference?
Compilation failed: 3 error(s), 0 warnings
stdout
Standard output is empty