- Home /
 
               Question by 
               castyll · Sep 14, 2016 at 03:05 AM · 
                unity 52dplatformer  
              
 
              Unity 2D: Reversed Gravity doesn't work
Hello Community, I'm working right now on a 2D Endless Runner to practice my skills. So far my game is looking pretty good and i'm trying to implement power up's now. One of them gives me trouble tho. It's a powerup, which after colliding with, makes the player fly with a strapped on angel costume for 5 seconds. The character flies in the air without any problem but he doesn't come back on the ground after that. I obviously also gave Gravity a standard value of 1 after the 5 seconds. Here's a snippet of my character powerup code:
   void OnTriggerEnter2D(Collider2D other)
     {
 
   if (other.gameObject.tag == "Energy")  //Powerup I'm talking about
         {
             Destroy(other.gameObject);
             StartCoroutine(energydrink());
                      
         }
 }
 
  IEnumerator energydrink()
     {
         speed = 15;
         rigidbody2d.gravityScale = -1;
         anim.SetBool("energydrink", true);
 
         yield return new WaitForSeconds(5);
 
         speed = 7;
         rigidbody2d.gravityScale = 1;
         anim.SetBool("energydrink", false);
 
 
 
 
     }
Thats how my game objects are arranged 
and my character inspector:

I would appreciate some help, thanks in advance!
 
                 
                objects.png 
                (8.1 kB) 
               
 
                
                 
                inspector.png 
                (74.8 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                