- Home /
My character is really jumpy/laggy
http://gyazo.com/e145a21952eb31d2f21e26a68e27ac69 Here is a low frame rate albeit fairly depictive gif, it's much more jumpy running live and if necessary I can upload to my server so you can play it and see what I mean, I am just using this game to learn but this really jumpiness is an annoyance that I can't solve..
Anyone have any idea? My movement is pretty much the script from the 2D example, its walking on top of a box collider of course, and has its own box collider and a ground check.
Are you using a circle collider for the character's feet? $$anonymous$$ight help
I am using a square collider and a jump check empty game object, thats all.
Answer by Madcowe · Oct 27, 2014 at 06:43 PM
First of all test if this works:
Go into the project settings (or the actual code) and remove the gravity, also make your character be above the ground and try moving. If he moves smoothly it means that the collision is getting "stuck" on the ground.
That is why many people add a "skin" variable to their collision detection scripts, usually something like 0.01f so there's that small gap between the player and the ground.
That is my guess on why it's like that
I disabled its rigidbody gravity, you can see it here http://gyazo.com/b7d89c38d2be3c2bc77388f6e3773522 it's still jumpy as usual, also I made sure you can see my rigidbody setup at the beginning of the gif, you will notice a collider in front of him, thats to stop him from getting stuck on the edge of platforms and stuff, it works pretty well, and I tried it with that disabled and same thing, so I doubt thats what's causing it.
Updateish, here's the inspector pane http://i.imgur.com/tZp2ThJ.png and if you see where it says Interpolate on the Rigidbody 2d, I turned that to none and when in no gravity it is very smooth now, look: http://gyazo.com/e15d4f1098818a71ff6cf0d108f42f0b
However.. turning gravity on to 0.65: http://gyazo.com/78bbecd35871f609c2ab47acbb1dc205 it gets JU$$anonymous$$PIER! (It's like 10X worse looking in real time lol, he literally becomes fairly blurry)
So.. I should I move my main collider down? or put one underneath him from his main collider and bump collider?
Is it possible he's running into the collider thats a few pixels in front of his main collider? http://i.imgur.com/qDN$$anonymous$$2H1.png
Hm that is very strange... my only guess at this point could be the angular drag? I don't know but it's strange... is your PC powerful? Or at least decent? As in, it's not a 10 year old machine right?
Thanks for all the help so far by the way, it means a lot, this is literally my first solo project outside of the tutorial projects so I am learning heavily here, thanks for the patience :)
To answer your question, my PC is plenty plenty fast enough, I have yet to meet a game I can't max out, so I would find it sooo awesomely funny if I couldn't run my own tiny 2d platform learning game lmao.
I turned the angular drag down and it still occured, I thought maybe if you saw the script it might help? I do warn once again that this is my first solo project so my coding is pretty horrible and I am using part of the 2D example code, and some of that extra code is wall jumping btw.
hm maybe it isn't the collisions, can I see your movement code or something like that?
I linked it above I believe: http://pastebin.com/fCEDuBjS
Answer by Marzoa · Oct 27, 2014 at 11:08 PM
If you have may animators, or animators that involves many objects, you may try setting "Culling Mode" of such animators to "Based on Renderers" instead of "Always". Just for trying anything else...
I don't have any animations yet, everything is very static because I am still in fairly early development.
It's really weird too because I don't remember this being an issue a few days ago now it is, I just don't know what might be happening..
In such case I would try disabling all objects' renderers in the scene and reenabling them one by one to see if I can isolate the problem in one object or just a group of them.
You may check also the quality settings, maybe unwittingly you changed them or something.
Hm I think the problem might be this piece. if(h rigidbody2D.velocity.x < maxSpeed) // ... add a force to the player. rigidbody2D.AddForce(Vector2.right h * moveForce);
Try using <= maxSpeed ins$$anonymous$$d and see if it helps
Oh my god.. I am a complete freaking moron.. I just solved what was going wrong, I went and started a new project and started importing the assets and stuff slowly into there testing it to see what was breaking and I noticed the movement was just fine on a collider elsewhere, so I added the camera in to track the player because I wanted to slowly add every other little bit in..
and it hit me.. It's the damn camera movement script.. As soon as I disabled the camera follow player script, the player rolled like butter..
This is the camera movement script: http://pastebin.com/7E2Ef$$anonymous$$Z4 any idea how I might improve that?
also thank you very much for your help, apologies for it being something so stupid lol, this has haunted me for the past near week, I am really glad that I finally posted xD
If you make the camera a child of your player it will always follow (Drag the camera on top of the player)
But if you want to use code why not just something like camera.x = player.x and so on? :P
Your answer
Follow this Question
Related Questions
Flat 2d image on 3d character. 0 Answers
when 2d character hits wall it shakes/bounces 1 Answer
how to add a walking animation when character is moving? 3 Answers
Ui sidescroller 2d touch ? 0 Answers