nicmar

This issue might be related to (Flickering when using Flip in Unity) but i'm not sure as the files wasn't there anymore.

I'm using an IK target to aim towards a target, and depending on what direction it's aiming, it's showing either the side or down view, by changing animations on several tracks. When aiming to the left, i want the spine transform to be flipped, but work the same otherwise.

The problem I have is that when I get to the point where it switches, it blinks for a frame in the other direction, before it being flipped.

See attachment:
https://www.dropbox.com/s/47iip9x6ney5vkf/glitch.mp4?dl=0

I've double checked, the flip command only runs once, and not back and forth as it seems. So it seems like it's Spine is changing the animation one frame after the flip is called, causing the glitch.

Things i tried:
- Putting the flip command in LateUpdate
- Put the spineAnimation in a child of the transform that is being flipped
- Change the flip to use localRotation -180 on y
- I tried putting skeletonAnimation.Update(0); after SetAnimation. I had used this on another rig with the comment "Update skeleton so it happens now, and not next frame (prevents flicker)". But it doesn't seem to have any effect.

I have this as a minimal repro project as well if this is complicated :)

Thanks!
We're making SpaceChef with Spine. An action filled cooking adventure. We're coming soon to Kickstarter, sign up for our newsletter to be the first to get notified: www.spacechefgame.com. Follow our work on Twitter @BlueGooGames.
Avatar utente
nicmar
  • Messaggi: 138

Harald

Typically such problems come from a missing skeletonAnimation.Update(0); call, but as you said that this did not resolve the issue, could you please send us your minimal repro project (as usual as a zip package to contact@esotericsoftware.com)? That should be the quickest way to find the cause of your issue.
Avatar utente
Harald

Harri
  • Messaggi: 4209

nicmar

Thank you, I have sent the repro project and also the spine files to you with the same subject as this forum post title.
I hope you find a magic command to solve it :)
We're making SpaceChef with Spine. An action filled cooking adventure. We're coming soon to Kickstarter, sign up for our newsletter to be the first to get notified: www.spacechefgame.com. Follow our work on Twitter @BlueGooGames.
Avatar utente
nicmar
  • Messaggi: 138

Harald

Thanks for sending the reproduction project, we received everything. I will get back to you as soon as I've figured out what's going wrong.

---

The problem was a bit tricky as the "usual suspects" are following along correctly and updating in correct order. What caused the problem is that the crosshair is a child of your Spine Container GameObject which is rotated 180 degrees to flip to the other side. Now when you flip the GameObject, the crosshair is suddenly no longer at the mouse position, but is flipped along with everything else. In the same frame the skeleton is updated again (which is good practice), but this time leading to the IK setup aiming at the wrong flipped crosshair location which did not yet update to the mouse position after it's parent has been mirrored.

I just quickly tested making FollowMouse.Update public and adding a call after FlipGraphicsRoot(), which fixes the issue:
FlipGraphicsRoot();
crosshairBone.GetComponent<FollowMouse>().Update();
(Of course that's not clean code, just a proof of concept.)
Avatar utente
Harald

Harri
  • Messaggi: 4209

nicmar

Very nice! I tested putting it outside the spine root, but still in the player object but didn’t get the correct result, but I will try your fix, looks promising.

Thank you so much for taking the time, I appreciate it a lot!
We're making SpaceChef with Spine. An action filled cooking adventure. We're coming soon to Kickstarter, sign up for our newsletter to be the first to get notified: www.spacechefgame.com. Follow our work on Twitter @BlueGooGames.
Avatar utente
nicmar
  • Messaggi: 138

Harald

Glad it helped!
nicmar ha scritto:outside the spine root, but still in the player object
The problem is that you're flipping (rotating Y 180) the player object, so you would need to move it even further up the hierarchy, but then other things would need to be adjusted accordingly since it's currently expecting to be flipped. My easier solution was therefore to just udpate the crosshair location to the mouse again. :)
Avatar utente
Harald

Harri
  • Messaggi: 4209


Torna a Unity