Koroldev Posted January 11, 2017 Share Posted January 11, 2017 Hi, guys! I have some problem. I am using function attachToBone for attaching a pistol to a hand of my game character. Sometimes if I change a character animations between shot and idle, pistol detaches from bone like on video. I think this is becouse in one moment a bone with pistol dos't animate, when an animation changes. But it is happens not always, often at low fps. And in old version of babylon 2.4 all works fine. But in version 2.5 it problem is appeared. Thanks for any considerations and ideas about it is problem. And it is problem if you ask me share on playground, this projects have many codes and models and other materials I shot the video Quote Link to comment Share on other sites More sharing options...
adam Posted January 11, 2017 Share Posted January 11, 2017 Maybe you could make a really simple PG that reproduces the issue. Here is an example of a PG I created when I had an issue with attachToBone: http://www.babylonjs-playground.com/#OCCLB#25 Koroldev 1 Quote Link to comment Share on other sites More sharing options...
Koroldev Posted January 11, 2017 Author Share Posted January 11, 2017 8 hours ago, adam said: Maybe you could make a really simple PG that reproduces the issue. Okay, I did it But I don't know how to load a models on the playground and I just create the archive file. In my example I created many Elipse2D for simulating low FPS, you can change value of count of Elipses for manipulating of FPS, for each PC it is own count of elipses In example just you need it is click mause as many time as you can and you see that sphere, which attached to bone sometimes detaches for one moment And one more fact, if you try to run this example in the version of babylon 2.4, all works fine, without a bone detaching example.rar Quote Link to comment Share on other sites More sharing options...
adam Posted January 11, 2017 Share Posted January 11, 2017 Can you see the issue here? http://www.babylonjs-playground.com/#OCCLB#26 I'm not able to reproduce it. edit: is this the issue? http://www.babylonjs-playground.com/#OCCLB#28 Why are you moving the mesh on line 46? Oh, you are simulating the movement of the character. Koroldev 1 Quote Link to comment Share on other sites More sharing options...
Koroldev Posted January 11, 2017 Author Share Posted January 11, 2017 17 minutes ago, adam said: Can you see the issue here? http://www.babylonjs-playground.com/#OCCLB#26 I'm not able to reproduce it. Yes, I shooted video with issue, sorry for big video resolution In some moment, the sphere detaching from bone, if I clicks my mouse Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 11, 2017 Share Posted January 11, 2017 I think Adam found the problem and you have to miss this: 42 minutes ago, adam said: edit: is this the issue? http://www.babylonjs-playground.com/#OCCLB#28 Why are you moving the mesh on line 46? Oh, you are simulating the movement of the character. Quote Link to comment Share on other sites More sharing options...
Koroldev Posted January 12, 2017 Author Share Posted January 12, 2017 15 minutes ago, Dad72 said: I think Adam found the problem and you have to miss this: Adam says Quote Oh, you are simulating the movement of the character. Yes, I am simulating the movement Like in first video in this topic And I think, that a mesh attached to bone, must working with movements bones Quote Link to comment Share on other sites More sharing options...
adam Posted January 12, 2017 Share Posted January 12, 2017 I thought I found a fix, but unfortunately it was a bug in my code. Quote Link to comment Share on other sites More sharing options...
Koroldev Posted January 12, 2017 Author Share Posted January 12, 2017 1 minute ago, adam said: I thought I found a fix, but unfortunately it was a bug in my code. Yes, I tried to write movement after render, but this do not helped I think the authors of the babylon js can help, if them will analyse version 2.5 and 2.4, because in the version 2.4 all works fine Quote Link to comment Share on other sites More sharing options...
adam Posted January 12, 2017 Share Posted January 12, 2017 This is interesting: http://www.babylonjs-playground.com/#OCCLB#32 That uses getAbsolutePosition of the bone instead of attachToBone. To keep the sphere on the bone while the mesh is moving, you have to move the sphere by the velocity of the mesh. Try commenting out line 32 and adjusting the velocity of the mesh. Koroldev 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted January 12, 2017 Share Posted January 12, 2017 Have you tried with version 2.6 ? Quote Link to comment Share on other sites More sharing options...
Koroldev Posted January 12, 2017 Author Share Posted January 12, 2017 15 minutes ago, Dad72 said: Have you tried with version 2.6 ? Yes, example, which adam share on playgraond are using version 2.6-alpha Quote Link to comment Share on other sites More sharing options...
Koroldev Posted January 12, 2017 Author Share Posted January 12, 2017 28 minutes ago, adam said: This is interesting: http://www.babylonjs-playground.com/#OCCLB#32 That uses getAbsolutePosition of the bone instead of attachToBone. To keep the sphere on the bone while the mesh is moving, you have to move the sphere by the velocity of the mesh. Try commenting out line 32 and adjusting the velocity of the mesh. Good idea, but this are simplified version of my game, where player keeps a weapon and haves heavy animations like wave of the hand and I need know not only position of a bone, but rotation too edit: I understood, maybe I can use bone.getRotation, okay, tomorrow I will apply this idea to my game and then I will write what came of Quote Link to comment Share on other sites More sharing options...
Koroldev Posted January 12, 2017 Author Share Posted January 12, 2017 9 hours ago, adam said: To keep the sphere on the bone while the mesh is moving, you have to move the sphere by the velocity of the mesh. I tried it's on my game and result even worse: tremble. Thank for help, will waiting for some news from the babylon developers Quote Link to comment Share on other sites More sharing options...
adam Posted January 12, 2017 Share Posted January 12, 2017 You could also try this: http://www.babylonjs-playground.com/#OCCLB#35 gunMesh.parent = characterMesh and then copy the absolute position of the bone to the gun. Notice I do not pass the mesh to the bone.getAbsolutePosition on this example. with rotation: http://www.babylonjs-playground.com/#OCCLB#36 It would be nice if attachToBone worked though, because I'm sure it's more efficient. Quote Link to comment Share on other sites More sharing options...
adam Posted January 12, 2017 Share Posted January 12, 2017 After all that, I think the very first PG actually works correctly. http://www.babylonjs-playground.com/#OCCLB#26 http://www.babylonjs-playground.com/#OCCLB#37 Edit: I think it's because you are rendering the scene again. Here I commented out scene.render(): http://www.babylonjs-playground.com/#OCCLB#38 So it actually isn't the ideal solution. Koroldev 1 Quote Link to comment Share on other sites More sharing options...
Koroldev Posted January 12, 2017 Author Share Posted January 12, 2017 7 hours ago, adam said: http://www.babylonjs-playground.com/#OCCLB#38 So it actually isn't the ideal solution. I don't understand how it's works without scene.render(), I get white screen if commented out scene.render() Quote Link to comment Share on other sites More sharing options...
adam Posted January 12, 2017 Share Posted January 12, 2017 The playground has its own render loop. https://github.com/BabylonJS/Babylon.js/blob/master/Playground/index.js#L167 Koroldev 1 Quote Link to comment Share on other sites More sharing options...
Koroldev Posted January 12, 2017 Author Share Posted January 12, 2017 1 hour ago, adam said: The playground has its own render loop. https://github.com/BabylonJS/Babylon.js/blob/master/Playground/index.js#L167 And what I need to change in my game code? If on playground you commented scene.render(), but how can I run my game without render? Quote Link to comment Share on other sites More sharing options...
adam Posted January 12, 2017 Share Posted January 12, 2017 30 minutes ago, negrant said: If on playground you commented scene.render(), but how can I run my game without render? That didn't fix the issue. That just demonstrated that on the playground the issue seemed to be fixed with the extra render call in a separate renderLoop. The best fix that I've been able to come up with is this: http://www.babylonjs-playground.com/#OCCLB#36 I'm thinking that @Deltakosh can get attachToBone working the way it should in this situation, though. Especially if it was working in 2.4. Quote Link to comment Share on other sites More sharing options...
Koroldev Posted January 13, 2017 Author Share Posted January 13, 2017 adam, thank for help. Then I will be waiting for some help or informations from Deltakosh Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 13, 2017 Share Posted January 13, 2017 Hello! I did not follow the thread. Do you mind giving me a summary? Quote Link to comment Share on other sites More sharing options...
adam Posted January 14, 2017 Share Posted January 14, 2017 AttachToBone doesn't keep the mesh attached properly between animations when the mesh of the skeleton is moving. This PG demonstrates the issue: http://www.babylonjs-playground.com/#OCCLB#28 Click to see the mesh jump to the left. Quote Link to comment Share on other sites More sharing options...
adam Posted January 14, 2017 Share Posted January 14, 2017 It works properly in 2.4: https://jsfiddle.net/usxek13s/3/ Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 19, 2017 Share Posted January 19, 2017 I'm a little bit swamped out recently. Do you have some free cycles to look at it? 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.