TheComputerGuy Posted October 27, 2014 Share Posted October 27, 2014 i using the dude complex mesh for an example.. but im trying to have him loaded as main player then be able to clone him with skeleton on keydown to test the clone ability. here is what i got.... // Dude BABYLON.SceneLoader.ImportMesh("him", "models/", "Dude.babylon", scene, function (newMeshes, particleSystems, skeletons) { newMeshes[0].position = new BABYLON.Vector3(0, 0, 5); // The original dude var dude = newMeshes[0]; dude.scaling = new BABYLON.Vector3(0.05,0.05,0.05); CREAT = dude; _CREAT = skeletons[0]; follow.target = CREAT; // target });window.addEventListener("keydown", function (evt) { switch (evt.keyCode) { case 83: createdude(); break; default: break; }var createdude = function () { dudes = []; var xrand = Math.floor(Math.random() * 501) - 250; var zrand = Math.floor(Math.random() * 501) - 250; var c2 = CREAT.clone(CREAT.name); c2.id = CREAT.name+(dudes.length+1); c2.position = new BABYLON.Vector3(xrand, 0, zrand); c2.skeleton = _CREAT.clone(); scene.beginAnimation(_CREAT, 0, 120, 1.0, true); };when i execute my code.. i get no errors in the console and nothing happens? what might i be doing wrong... my main character loads but thats it. ty for all the help. Quote Link to comment Share on other sites More sharing options...
Temechon Posted October 27, 2014 Share Posted October 27, 2014 Do you have a running example somewhere ? Your code looks fine. TheComputerGuy 1 Quote Link to comment Share on other sites More sharing options...
TheComputerGuy Posted October 28, 2014 Author Share Posted October 28, 2014 Do you have a running example somewhere ? Your code looks fine.yes, https://gamesite.x10.mx/avaworld/ and the key that should clone is the "s" key... ty Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted October 28, 2014 Share Posted October 28, 2014 yes, https://gamesite.x10.mx/avaworld/ and the key that should clone is the "s" key... ty As far as I can tell, you're using the same name for both meshes. Try changing the name. The error isUncaught TypeError: Cannot read property 'applyToMesh' of undefined babylon.1.14-beta-debug.js:7791Mesh.clone babylon.1.14-beta-debug.js:7791createdude Game.js:179(anonymous function) Quote Link to comment Share on other sites More sharing options...
Temechon Posted October 28, 2014 Share Posted October 28, 2014 The problem is not the name here. Actually, the object CREAT represents a dummy object, and thus has no geometry. If you try to clone it, it won't work. However, I think this case should be handled by babylon... @Deltakosh, what do you think ? Quote Link to comment Share on other sites More sharing options...
Stephen Andrews Posted October 28, 2014 Share Posted October 28, 2014 The problem is not the name here. Actually, the object CREAT represents a dummy object, and thus has no geometry. If you try to clone it, it won't work. However, I think this case should be handled by babylon... @Deltakosh, what do you think ?Ah okay, I thought CREAT was a standard mesh. Quote Link to comment Share on other sites More sharing options...
TheComputerGuy Posted October 28, 2014 Author Share Posted October 28, 2014 The problem is not the name here. Actually, the object CREAT represents a dummy object, and thus has no geometry. If you try to clone it, it won't work. However, I think this case should be handled by babylon... @Deltakosh, what do you think ? So, should i make dude a global var and use it instead of the CREAT? Quote Link to comment Share on other sites More sharing options...
Temechon Posted October 28, 2014 Share Posted October 28, 2014 No, the problem is not the CREAT problem. The problem is that CREAT is a reference to newMeshes[0], and newMeshes[0] has no geometry.You should clone newMeshes[1], [2], ..., but not [0]. TheComputerGuy 1 Quote Link to comment Share on other sites More sharing options...
TheComputerGuy Posted October 28, 2014 Author Share Posted October 28, 2014 No, the problem is not the CREAT problem. The problem is that CREAT is a reference to newMeshes[0], and newMeshes[0] has no geometry.You should clone newMeshes[1], [2], ..., but not [0].So, if i understand right, the CREAT allows me to adjust position and what not but not the actual mesh. The reason i ask is because i am able to make changes to dude like position and such. Would you possibly be able to show me an example to how i could reference the correct mesh? ty either way Quote Link to comment Share on other sites More sharing options...
TheComputerGuy Posted October 29, 2014 Author Share Posted October 29, 2014 I figured it out...var createdude = function () { dudes = []; var xrand = Math.floor(Math.random() * 501) - 250; var zrand = Math.floor(Math.random() * 501) - 250; var c = []; for (j = 1; j < newMeshes2.length; j++) { c[j] = newMeshes2[j].clone("c" + j); c[j].position = new BABYLON.Vector3(xrand, 0, zrand); c[j].scaling = new BABYLON.Vector3(0.05,0.05,0.05); c[j].skeleton = newMeshes2[j].skeleton.clone(); scene.beginAnimation(c[j].skeleton, 0, 120, 1.0, true); } };ty for all your help Quote Link to comment Share on other sites More sharing options...
Temechon Posted October 29, 2014 Share Posted October 29, 2014 Cool 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.