I'm currently testing my iOS build and am having some issues with character movement.
In the editor everything works fine. But when testing on iPad character movement
becomes glitchy. Walking seems to be OK (I think) but when running in
one direction a single frame of the opposite run animation will often
show (I only have left and right animations, no up/down). Also,
occasionally, when the character stops, the animation will flip
rapidly between the left and right run animations for a second or two
instead of returning to idle.
No such problems on android.
Character is animated with Sprites Unity Complex and motion control is set to Automatic.
The game is 2D. Movement method = point and click, Input method = touch Screen,
NavMesh search % = 0.8, NavMesh search direction = straight down from
cursor, Destination accuracy = 1, Pathfinding update time = 0.
Any ideas?
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
So when making a beeline (no NavMesh edges getting in the way), the opposite animation plays mid-run, or only at the start/end?
Are you able to take a video? As Its a visual problem seeing it occur would help understand it better.
How have you set up your transitions to switch between the left/right animations? Please post shots of your Animator Controller and the way your transitions are built / what parameter conditions they rely on.
So the R -> L transition occurs if the angle < 180. Is the opposite true for L -> R?
It may be that when the character's angle becomes exactly 180, the controller gets confused and the conditions for both transitions become true at the same time.
Try lowering the angle threshold, ie. R->L if angle < 170, L->R if angle > 190. That way, it won't immediately switch when 180 degrees, but close enough to it so that the character will still face left/right appropriately.
What Unity version are you using?
A couple of ideas:
1) Try using the Direction integer parameter, instead of the Angle float parameter
2) Try removing the L -> R transitions altogether and see if the glitching still occurs
3) Try auto-connecting the editor up to the device while running, and then use Debug.Log statements to confirm the angle float parameter value:
void Update ()
{
Debug.Log ("Angle is : " + KickStarter.player.GetSpriteAngle ());
}
There's a "Sprites Unity Complex" variant of the 2D Demo's player character, Brain2D_SpritesUnityComplex, located in the /AdventureCreator/2DDemo/Resources folder. If you drop him into the scene so that he becomes the player, does the same thing occur? Conversely, what if you load in the 2D Demo's Managers, and the 2D Demo scene, but have your own Player prefab in the scene instead?
Try loading up your own game's Managers, and load up the 2D Demo scene with your own Player. Unset the "On Start cutscene" field so that playing the scene immediately begins gameplay. What then? If the game runs OK, I'd say it's going to lie with your scene - otherwise it could be your Managers.
How large is your player character's sprite compared to that of the 2D Demo? Would you mind also posting a shot of the Player's full Inspector window?
It could be due to your massive Acceleration / Deceleration values - try lowering them to something more reasonable. Generally 30 should be as high as you need in most cases.