- Home /
The new Unity Update Messed Up My Project a bit, Please help?
Okay, first off, and most annoying for me, Is Unity now wants to Open Virtual Studio to open up my scripts instead of MonoDevelop. How do I change this?
Also, I used AddForce on a RigidBody (My game character beforehand. Before the update it worked perfectly, but Now for some reason When I walk up and down specifically, I shoot ridiculous speeds. instead of walking normally like left and right still do.
rbody.AddForce(Vector2.up * walkspeed);
rbody being my characters ridgidbody. Walkspeed being an int of 150.
UPDATE: I am currently fiddling with Unity, and I turned off something called "Apply Root $$anonymous$$otion" in the animator, and it turned my Walking Left and right into the same as up and down. I believe that means I am closer, but now my character is flying all over the place.
Answer by Adarn · Sep 19, 2016 at 11:47 PM
Apply root motion basically means that any movement within your animation is applied to your game objects location. This this means that your animation drives your movement instead you adding forces.
Are you working with RigdigBody2D or RigidBody? I'm going to assume 2D.
Also when you say it walks left and right correctly but not up and down, does this mean your game is a top down perspective? where up and down are still walking movements for your character? If this is the case you should be able to apply the same methods you have used for left and right movement to your up and down. Which if you are using ApplyRootMotion means that you need to have animations for up and down built in the same way you have built your left and right.
Also when you are applying a force through addForce you do not need to use deltaTime. This is because the physics engine has a fixed step size and the force is applied during this step.
Yes, It is a topdown game. Unfortunately the style I chose does not have Animations for walking up or down. Just walking, and if facing left and right. Here is a quick webm showing what I have done so far https://zippy.gfycat.com/FamousDeliriousFiddlercrab.webm
Im surprised the last version of Unity Allowed me to walk normally using this same code if you're saying It hasn't even been the code. But I never even had an animation of my character facing up.
Well if I DO need an animation to give my character upward force etc. Is it possible we could still use the current AddForce $$anonymous$$ethod for movement if I uncheck the root movement? I was testing many movement methods for the character and AddForce didn't cause any jitter when colliding with solids which is why I wanted to use it for movement. I guess the problem now, is that $$anonymous$$y character has no friction? Before the update I had it where you walked, then you started walking, if you stopped you stopped in place and began idle animation etc.
But now, Force is being added, and because my characters gravity scale is 0 to prevent it from falling down on the screen, it also seems to be hovering, and therefore has no friction, and does not Stop Immidiately after moving. The second issue I guess would be limiting the speed of the force, and I would like it to have a feeling of "Full force" to "No Force" just the go and stop like you might be able to see from the Webm link I posted above.
Ok its a bit clearer now. It doesn't look like you will be able to use root motion with the animations that you have. As all directions of your movement are the same (ie walking around) it would be best not to mix how you handle the movement. That means don't do left and right different to up and down.
As you said you like how your collisions are handled when using AddForce then this is going to be the way to go.
You have disabled gravity which is correct. What you need to do now is give your RidgidBody2D some linear drag (RifigBody2D.drag). What this is, generally speaking is how much resistance the body has to moving and how fast velocity will decay when no force is applied. The higher this value the quicker the body will come to a stop when you are no longer adding force.
Now for the movement. You will need to check the velocity of your body when you are adding force to make sure you don't exceed what you want your maximum velocity to be. If you don't check this and just keep pushing it will just move faster and faster until you stop pushing. (Which is your current issue). You may even need to force the velocity back down to your max if its is exceeded.
This might seem like a complete redesign of what you have done, but it will be best for you to make the movement in all directions handled consistently rather than handling horizontal movement differently to vertical.
Sorry for the long reply. I understood! In the end, I opted for using rbody.velocity ins$$anonymous$$d of AddForce. The reason for this was because my old build must have acted differently due to the Apply Root $$anonymous$$otion being on, and me just not noticing before, therefore making my animation work over the velocity before when I tested it making it jittery. Because of the way I want my game to feel snappy, I had to opt in to just changing the velocity all the way up, and down using if statements inside my code. It took me a while to work out some of the bugs and exactly how to instate it ins$$anonymous$$d of AddForce but here is the result if you're curious ;)
Answer by Jessespike · Sep 19, 2016 at 09:44 PM
Edit -> Preferences -> External Tools
Set External Script Editor to MonoDevelop.
As for the force, I'm not sure. I find it odd that there's no Time.deltaTime included though.
rbody.AddForce(Vector2.up * walkspeed * Time.deltaTime);
or Time.fixedDeltaTime if it's in FixedUpdate.
Hello! You fixed the $$anonymous$$onoDevelop Problem, so Thank you!
As for the force, it still seems to be broken. The solution you provided did nothing at all.
$$anonymous$$y character has 0 GravityScale on its ridgid Body, This makes me think its possible that $$anonymous$$y character is specifically flying upward because the force is making me fly upward, But walking left and right does not do this unless I uncheck "Apply Root $$anonymous$$otion" in the Animator component $$anonymous$$y character has. But when The Apply Root $$anonymous$$otion is on, $$anonymous$$y character walking left and right is just fine, like before the update, but Up and down still make me fly.