fork(32) download
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class hareket : MonoBehaviour {
  6. public float moveSpeed = 15f;
  7.  
  8. public float speed;
  9. public float jumpForce;
  10. private float moveInput;
  11.  
  12. private Rigidbody2D rb;
  13. private bool facingRight = true;
  14.  
  15. private bool isGrounded;
  16. public Transform groundCheck;
  17. public float checkRadius;
  18. public LayerMask whatIsGround;
  19.  
  20.  
  21. private int extraJumps;
  22. public int extraJumpsValue;
  23.  
  24. void Start(){
  25. extraJumps = extraJumpsValue;
  26. rb = GetComponent <Rigidbody2D> ();
  27. }
  28.  
  29. void FixedUpdate(){
  30.  
  31. isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, whatIsGround);
  32.  
  33. moveInput = Input.GetAxis("Horizontal");
  34. rb.velocity = new Vector2 (moveInput * speed, rb.velocity.y);
  35.  
  36. if(facingRight == false && moveInput > 0){
  37. Flip();
  38. } else if(facingRight == true && moveInput < 0){
  39. Flip();
  40. }
  41. }
  42.  
  43. void Update(){
  44. Jump();
  45. Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);
  46. transform.position += movement * Time.deltaTime * moveSpeed;
  47. }
  48. void Jump(){
  49. if (Input.GetButtonDown("Jump")){
  50. gameObject.GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, 25f), ForceMode2D.Impulse);
  51. }
  52. if(isGrounded == true){
  53. extraJumps = extraJumpsValue;
  54. }
  55.  
  56. if(Input.GetKeyDown(KeyCode.UpArrow) && extraJumps > 0){
  57. rb.velocity = Vector2.up * jumpForce;
  58. extraJumps--;
  59. } else if(Input.GetKeyDown(KeyCode.UpArrow) && extraJumps == 0 && isGrounded == true){
  60. rb.velocity = Vector2.up * jumpForce;
  61. }
  62. if (isGrounded == false)
  63. {
  64. extraJumps = 0;
  65. }
  66. }
  67.  
  68. void Flip(){
  69.  
  70. facingRight = !facingRight;
  71. Vector3 Scaler = transform.localScale;
  72. Scaler.x *= -1;
  73. transform.localScale = Scaler;
  74. }
  75. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(1,7): error CS0246: The type or namespace name `UnityEngine' could not be found. Are you missing an assembly reference?
prog.cs(5,24): error CS0246: The type or namespace name `MonoBehaviour' could not be found. Are you missing an assembly reference?
prog.cs(12,10): error CS0246: The type or namespace name `Rigidbody2D' could not be found. Are you missing an assembly reference?
prog.cs(16,9): error CS0246: The type or namespace name `Transform' could not be found. Are you missing an assembly reference?
prog.cs(18,9): error CS0246: The type or namespace name `LayerMask' could not be found. Are you missing an assembly reference?
Compilation failed: 5 error(s), 0 warnings
stdout
Standard output is empty