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

How would I add an air dash and jump/double jump to this script??

Discussion in 'Scripting' started by ultimateronsu17, Aug 21, 2015.

?

would you like to help me with my fan game??

  1. yes

    4 vote(s)
    80.0%
  2. no

    3 vote(s)
    60.0%
Multiple votes are allowed.
  1. ultimateronsu17

    ultimateronsu17

    Joined:
    May 30, 2015
    Posts:
    34
    I've been thinking lately with this free form directional mechanic in mecanim and having my character run in this way is awesome and thanks to those who help me but i'm stuck on 2 things so far
    1. creating an air dash with mecanim
    2.creating a jump/double jump with mecanim
    *note the following code is free of use if you wan't you character to move like in my previous post


    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Movement : MonoBehaviour {
    5.  
    6.     Animator anim;
    7.  
    8.     bool grounded = false;
    9.     public Transform groundCheck;
    10.     float groundRadius = 0.2f;
    11.     public LayerMask whatIsGround;
    12.  
    13.  
    14.     // Use this for initialization
    15.     void Start () {
    16.      
    17.         anim = GetComponent<Animator> ();
    18.     }
    19.  
    20.     void FixedUpdate (){
    21.  
    22.         grounded = Physics2D.OverlapCircle (groundCheck.position, groundRadius, whatIsGround);
    23.         anim.SetBool ("Ground", grounded);
    24.  
    25.     }
    26.  
    27.     // Update is called once per frame
    28.     void Update () {
    29.  
    30.         float input_x = Input.GetAxisRaw ("Horizontal");
    31.         float input_z = Input.GetAxisRaw ("Vertical");
    32.  
    33.         bool IsWalking = (Mathf.Abs (input_x) + Mathf.Abs (input_z)) >0;
    34.         anim.SetBool ("IsWalking", IsWalking);
    35.         if (IsWalking)
    36.         {
    37.             anim.SetFloat ("x", input_x);
    38.             anim.SetFloat ("z", input_z);
    39.  
    40.             transform.position += new Vector3(input_x, 0f, input_z).normalized * Time.deltaTime;
    41.             if (grounded && Input.GetKeyDown (KeyCode.Space))
    42.             {
    43.                 anim.SetBool ("Ground",false);
    44.             }
    45.         }
    46.     }
    47. }
    I actually think I know how to get my character running on walls and such and a fighting system but i'm just stuck at this part so I can't move on to my attacks with out mobility so any suggestions thanks :)
     
  2. ultimateronsu17

    ultimateronsu17

    Joined:
    May 30, 2015
    Posts:
    34
    Someone help? Please?
     
  3. BudBroesky

    BudBroesky

    Joined:
    Nov 11, 2013
    Posts:
    15
    Just responded to your other post.
     
  4. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    There's 3 of these posts
     
  5. ultimateronsu17

    ultimateronsu17

    Joined:
    May 30, 2015
    Posts:
    34
    anyone who see's this do not reply to this thread i'm trying to figure out how to delete this one since it's 3 threads like this :)