Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

(sprite2D) Movement like this game...

Discussion in 'Scripting' started by Naografix, Sep 16, 2014.

  1. Naografix

    Naografix

    Joined:
    Sep 16, 2014
    Posts:
    16
    Hey !

    I have a small problem with my game, i want to create a game similar of this game (the movement) : http://armorgames.com/play/10912/space-is-key

    And i made this : (I'm new in Unity :/)

    Code (CSharp):
    1. void jump()
    2.     {
    3.         if (Input.GetKey(KeyCode.Space) && Global.isGrounded == true)
    4.         {
    5.             rigidbody2D.AddForce(Vector3.up * jumpForce);
    6.             isJumped = true;
    7.         }
    8.         else if(Global.isGrounded == false)
    9.         {
    10.             rigidbody2D.AddForce(-Vector3.up * jumpForce / slowJump);
    11.         }
    12.  
    13.  
    14.         if (Global.isGrounded == false)
    15.         {
    16.            targetAngles = transform.eulerAngles - 180f * Vector3.forward;
    17.            transform.eulerAngles = Vector3.Lerp(transform.eulerAngles, targetAngles, speedRotation * Time.deltaTime);
    18.         }
    19.  
    20.     }
    21.  
    22.     //MOVEMENT
    23.     void Movement()
    24.     {
    25.         transform.Translate(Vector2.right / slowSpeed, Space.World);
    26.     }
    I dont know how can i improve my movement and my jump... Can you help me ?
     
  2. Lars-Kristian

    Lars-Kristian

    Joined:
    Jun 26, 2013
    Posts:
    64
    If you upload a .gif on how the movement and jump looks like it will be easier for us to help.
    I recommend Gifcam. :)
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,744
    For a start, I can tell you for certain that that game does not use physics. And using physics is just going to trip you up.
     
  4. Naografix

    Naografix

    Joined:
    Sep 16, 2014
    Posts:
    16