simple_life Posted May 3, 2018 Share Posted May 3, 2018 Hello,I've added left and right moves, but I don't know why I'm moving in the wrong direction .How do you get rid of the jitter of the collision? https://www.babylonjs-playground.com/#1FMV26#12 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 7, 2018 Share Posted May 7, 2018 Hi SL, sorry for the slow replies. Your Q and D keys (left and right) will move in the correct directions IF the camera is turned in a certain, perfect direction. But that sucks, eh? *nod* https://www.babylonjs-playground.com/#1FMV26#16 I did some camera and player de-rotating (squaring-up)... and some hacking-around in lines 76-91. Q and D keys are working nicely (a bit fast)... but... when we turn the camera... the Q/D keys direction... does not follow. In other words, still broken. I will continue work in the morning. We're close to fixing it. The collision "jitter"... that's... a rough issue. I'm not sure how to explain it, but I will try. moveWithCollisions() (used often in this PG)... needs to REVERSE any collision "state" that happens, or else it would get stuck in permanent collision state. It must back-out of collision states ('clear' the collision)... to "oldPosition". But keyboard keys repeat, if held, right? So, what you are seeing... is repeating keypresses and the moveWithCollisions collider... constantly clearing itself (backing out). This theory... is only speculation. I could easily be wrong. I have not studied the colliding system very thoroughly. There is one POSSIBLE way to avoid the expected jitter. A "prediction" system. Essentially, when a move is requested, you FIRST do invisibleBox.moveWithCollisions(same amount)... and somehow see if it collides (programmatically). IF it does collide, refuse to move the actual player. It's sort of like "Hey ghost player... make this move and see if you collide." If you want to get fancy... you could send ghost player to check for collide. --- If collide: --- Divide move distance in HALF, and try again. --- If ghost half-distance-move succeeds, then move player half-distance. --- If ghost half-distance-move collides, refuse to move player. --- else If NO collide: --- Move player requested distance. Maybe you, and/or the overnight forum helpers... will help us add these things to our playground demo. Otherwise, I'll be back soon. Be well. simple_life 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 7, 2018 Share Posted May 7, 2018 Okay, here we go. https://www.babylonjs-playground.com/#1FMV26#17 Q and D keys (strafe left/right without animation) seems to be working fine, at any camera angle. Yay! Lines 75-82 have been adjusted. To get leftward and rightward values, I used the camera's X and -X directions. It might not be the best way to get a left/right direction, but it works. I'm no expert at direction-finding. I once got lost in my own bathroom! Hopefully, we'll get some more comments about collision jitter. Perhaps someone will get ballsy and try to implement that collision-prediction idea from the previous post. I heard a rumor that @Dad72, the genius author of this scene... will help us reverse-the-order of the animation .data (the keys), for backwards walking ('s' key). I wonder if that rumor is true. hmm. simple_life 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2018 Share Posted May 7, 2018 For the animation of the backwards walking, it is necessary to create the animation of backwards walking. Same thing for right and left animations. But this character does not have one. I do not know where the rumor comes from that I could reverse the animation order ? False rumor. ? simple_life 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted May 7, 2018 Share Posted May 7, 2018 Small improvement of the scene : https://www.babylonjs-playground.com/#1FMV26#18 simple_life 1 Quote Link to comment Share on other sites More sharing options...
simple_life Posted May 8, 2018 Author Share Posted May 8, 2018 Thank you for your help Wingnut 1 Quote Link to comment Share on other sites More sharing options...
Wingnut Posted May 8, 2018 Share Posted May 8, 2018 Our pleasure, SL! Maybe we will do more work on "jitter control"... in this thread, too. @Dad72 - https://www.babylonjs-playground.com/#1LNWLE#3 From: http://www.html5gamedevs.com/topic/20754-questions-about-animatables-animations/?do=findComment&comment=119020 I tried to "ping-pong cycle" the rabbit animation, and with DK's help, #3+ PG... DID work. (By reversing the keys - lines 39-59 pingpong() func.) But, it doesn't work anymore. Oh no! It was a long time ago. Maybe not so easy to reverse animations... in newer BJS versions. I wish we had ANIMATIONLOOPMODE_PINGPONG, or possibly ANIMATIONLOOPMODE_REVERSE options... in BJS. (Not for 'dude', but for other uses.) But, perhaps, not a good idea. I am not so good-at seeing "FRR" (far-reaching ramifications - of creating ANIMATIONLOOPMODE_PINGPONG). It would probably break 20 other things. simple_life 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.