Need help With C# Script

I am trying to make a movement script for a 2d game. Right now whats on the script is that it’s going to track the sprite then when pressing a certain button the sprite will jump/move that kind of thing but I just can’t seem to get it all right and there is always a problem. Is there anyway someone could try to clean it up for me, or help me to see what’s wrong.

2633991–185186–Movement.cs (2.17 KB)

First of all, any reason why you are not using Unity´s built-in physics?

Are you talking about adding a character controller and using That to move the character around?

Hmmm no, Im talking about physics (rigidbodies, forces etc).
Im asking because (if i can recall) you implement your own gravity.
The script is kinda mesh but in order to clean it up a little we have to know (and you too :slight_smile: ) what you are exactly trying to do with it.

Check this official tutorial with script included:
https://unity3d.com/es/learn/tutorials/modules/beginner/live-training-archive/creating-a-basic-platformer-game

Actually, it’s often smart not to use the built-in physics for this sort of thing; you can have a lot more control moving things yourself.

Please check out this article on 2D animation methods for some good working code that does what it sounds like you’re trying to do. (Scroll to the bottom of the article for a link to a webplayer demo.)