- Home /
 
               Question by 
               BrayanKrad03 · May 18, 2017 at 11:06 AM · 
                raycastanimatorjumpcollision detectioncrouch  
              
 
              I want to make a character jump and crouch without using boolean
I want to make a character can crouch and detect that there is something up the character by way of Raycast and that skipping with raycast and collision detector but I do not want to use bolean because I want the character movement to be more fluid, thanks in advance here is my very simple script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Movement : MonoBehaviour { Animator Anim;
 bool isAiming = false;
 const float WALK_SPEED = .5f;
 void Awake()
 {
     Anim = GetComponent<Animator> ();
 }
     
 void Update()
 {
     Aiming ();
     Move ();
 }
     
 void Aiming()
 {
     if (Input.GetKeyDown (KeyCode.Mouse1)) {
         isAiming = !isAiming;
         Anim.SetBool ("Aiming", isAiming);
     }
     if (Input.GetKeyUp(KeyCode.Mouse1)) {
         isAiming = !isAiming;
         Anim.SetBool ("Aiming", isAiming);
     }
 }
 void Move ()
 {
     if (Anim.GetBool ("Aiming"))
     {
         Anim.SetFloat("MoveZ", Mathf. Clamp(Input.GetAxis("MoveZ"),-WALK_SPEED,WALK_SPEED));
         Anim.SetFloat("MoveX", Mathf. Clamp(Input.GetAxis("MoveX"),-WALK_SPEED,WALK_SPEED));
     }
     else
     {
         Anim.SetFloat("MoveZ", Input.GetAxis("MoveZ"));
         Anim.SetFloat("MoveX", Input.GetAxis("MoveX"));
     }
 }
}
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
issues with jumping and linecast2d and raycast2d 0 Answers
Detecting tags on an animated gameobject 0 Answers
jump linecast 0 Answers
How can I let the ray to the edge of the capsule? 1 Answer
Raycast problem trough the terrain 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                