Hello There, I upgraded my project to Unity5 this week and it seems that my Rigidbody2D now floats my GameObjects, in this case my ground enemy (the top hat velociraptor). To give an example, this is how it worked before and how it is currently working. I also tried recreating the entire GameObject and that seems to do other weird things. You can see that here. It seems that my ground variable is doing something weird. You can check out my full code for this GameObject here as well. I know the condition for jumping isn't perfect, its something I'm working on and I'm not sure how to get to work naturally. I also know my code is a little scattered, if anyone has tips on improving it I'll be happy to take advice. Here is my jump condition to help out. Code (csharp): if (dir.y > 0 && grounded && anim.GetBool("Ground")){ // Add a vertical force to the enemy. grounded = false; anim.SetBool("Ground", false); rb.AddForce(new Vector2(0f, jumpForce)); } Thanks!
No, I didn't change it at all when upgrading. :/ meh. I have it set to the same as my player, this is it below:
I have it turned off and get the same same result. I can upload my project to github if anyone would like to take a look at it that way.
I tried you code and for me the problem with floating was solved when I unchecked "Apply Root Motion" (as MelvMay suggested). The enemey sometimes jumped rather high, but it always returned to the ground.
It seems that I overlooked that. My apologies. Thank you for your help! As far as the jumping, I don't have a great condition at the moment. Pretty much, if the enemy is grounded and his position is greater than 0 on the Y axis he jumps. Any tips on improving this?