Question by 
               theWoollygoat · Jun 30, 2016 at 05:08 PM · 
                2dnewbiesidescroller  
              
 
              how do i make my character float down?
i'm making a 2D sidescroller and i want the player to have the ability to press jump button while falling to float down. i already manege to script a falling detection but i don't know how to to make the character float down. i tried to add force up, translate up and set off the character gravity but non gave me the needed float effect.
public class stylefalling : MonoBehaviour {
 float Chight,time=0,Phight,delay=0;
 bool coll;
 public float d=0.1f;
 void OnCollisionEnter2D(Collision2D col){
     coll = true;
     time = 0;
     delay = 0;
     Chight = 0;
     Phight = 0;
     GetComponent<Rigidbody2D>().gravityScale=10;
 }
 void OnCollisionExit2D(Collision2D colll){
     coll = false;
 } 
 void Update () {
     if (coll == false)
         Chight = transform.position.y;
         time = Time.time;
     if (coll == false && time > delay) {
         Phight = transform.position.y;
         delay = Time.time+d;
     }
     if (Phight > Chight && Input.GetKey (KeyCode.Space)&&coll==false) {
         GetComponent<Rigidbody2D>().gravityScale=0;
     }
     if (Input.GetKeyUp (KeyCode.Space)) {
         GetComponent<Rigidbody2D>().gravityScale=10;
     }
     }
 }
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Dialogue & stop walking 1 Answer
How to use Shadow Caster 2D with Tilemap? 0 Answers
Get local position of pointer on scaled texture (2D) 1 Answer
Spawner design for variable spawned units 1 Answer
Can't find anything to help me! 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                