Question by 
               pwego · Aug 26, 2015 at 10:03 PM · 
                2dcollider2dplatformerknockback  
              
 
              knockback only working for y. X wont work for anything.
As far as i see this should be working, the code is responsive and shows with knockback for y, but no matter what i put in there for x nothing happens. Ive tried just typing numbers, modifying the knockback in the inspector just increases the height of the knockback.
All knockback code is isolated in this one script.
 float moveVelocity;
 public float knockback;
 public float knockbackLength;
 public float knockbackCount;
 public bool knockFromRight;
     void OnTriggerStay2D(Collider2D other)
     {
 if (knockbackCount <= 0){
             GetComponent<Rigidbody2D> ().velocity = new Vector2 (moveVelocity, GetComponent<Rigidbody2D> ().velocity.y);
     }
         else {
             if (knockFromRight){
                 GetComponent<Rigidbody2D> ().velocity = new Vector2 (-knockback, knockback);
             }
             if (!knockFromRight){
                 GetComponent<Rigidbody2D> ().velocity = new Vector2 (knockback, knockback);
             }
             knockbackCount -= Time.deltaTime;
         }}
                     void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag ("doesdmg")) {
         knockbackCount = knockbackLength;
         if(other.transform.position.x > transform.position.x)
             knockFromRight = true;
         else
             knockFromRight = false;
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
2D Cast Problem 0 Answers
Player slips through the tilemap collider 2D. 0 Answers
My character seems to glitch out after touching trigger colliders. 0 Answers
2D Collider out of screen 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                