- Home /
Stuttering and trigger issues after switching player sprite.
Hi,
My project is a 2D game and I decided to use the standard 2D player prefab from the Unity Assets Beta pack (found here: https://www.assetstore.unity3d.com/en/#!/content/14474) as it does exactly what I need so I figured there's no point writing my own character controllers etc. I've been using this as a placeholder for a while now but have now finalized my character design and went onto swapping the sprite. What I did was:
1) Remove the sprite renderer with the old sprite attached 2) Imported, sliced, and added my sprite in pieces as child objects to the Player object (like in the Unity 2D demo project) 3) Animated the child objects with keyframes using Animation and replaced the old animations with my new ones in the Animator.
Nothing else was changed. Everything seemed fine. My character was animating nicely, but here's where some weird problems started occuring...
1) My character sprite keeps lagging when moving. Previously, movement was beautiful and smooth, but now there is a constant stutter. It's not significant enough to break the game I guess, but bothers me as the whole reason I went for Unity animation instead of spritesheets was to make everything silky smooth.
I've narrowed the problem down to the animator. If I remove that, my character moves perfectly smooth (albeit without animation, obviously). I've checked my animations many times and they're smooth and I see no issue. If I remove all the animations from the animator, but leave it enabled, the character stutters again (albeit without animation, obviously). Therefore the problem has to be the animator. I searched around and info about this is very scarce, but from what I managed to gather there seems to be a problem with Rigidbody and animator interfering with each other? Unfortunately both are necessary for me, so removing one isn't an option... Following some suggestions, I have the rigidbody set on Interpolate and "Animate Physics" ticked on the animator, but no effect. I've messed around with other options too but nothing. I'm completely clueless about this.
2) Swapping the sprite has also caused issues with triggers for whatever reason. It makes absolutely no sense to me, as my triggers are based on tags and no tags have been changed at all. Everything was working fine before with the old sprite. My player object is tagged player and is on the player layer, and I've even set the child objects to be the same just in case. For some reason though, the player is never detected anymore by triggers, but normal collisions are fine. I've tried to add a sprite renderer and using a sprite on the main object along with the children, but nothing. Something is very weird here, it's literally the same object as before but not working anymore.
Okay since this is rather long I'll end it here. If any more information (or scripts?) are required, I'll gladly post them.
Any ideas as to what might be causing my problems are welcome. Thanks in advance!
Answer by sten360 · Jun 05, 2014 at 11:54 AM
Oh my god... I've just upgraded from Unity 4.3 to the new 4.5 and the stuttering issue seems to be fixed. I suppose it was a bug or somekind of inefficiency in the previous Unity code after all. So happy right now, haha.
Trigger issue still persists, though.
Your answer
Follow this Question
Related Questions
Unity Animator Input Lag 0 Answers
How to play animation from an array of gameObjects? 0 Answers