Search the Community
Showing results for tags 'moveWithCollisions'.
-
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
-
Hi, I am simply trying to arrange items in a box (kind of like a shopping bag) however I am unable to "detect" collision correctly. In the example I created, I have two simple cylinders in a box; but the cylinders collide till the half of their radius. Also once they collide with the container (box) ... also half; you can never drag them back http://playground.babylonjs.com/#8CDJXW Could you please advice what I am doing wrong. Thanks, Dhiru
- 20 replies
-
- babylon js
- movewithcollisions
-
(and 1 more)
Tagged with:
-
Hi, I'm not 100% sure what's happening.. If meshPlayer.ellipsoidOffset.y is default 0 and you try to move on anything but a strait("flat") line, it bugs and collides instantly with the wall mesh without even being near. (See console.) E.g. destination.y = 1 && meshPlayer.position.y = 1 && meshPlayer.ellipsoidOffset.y = 0 === works, anything else doesnt seem to work unless setting ellipsoidOffset.y.. see lines 38, 47 & 49 & console. http://playground.babylonjs.com/#CBIPDN // Doesn't work, onCollide is triggered as if we hit the wall infront of us, even through we didn't. (no movement because of meshPlayer.destination = null; on collision detection) http://playground.babylonjs.com/#CBIPDN#1 // Works Any thoughts?
-
see https://www.babylonjs-playground.com/indexstable#97B3B7#12 Here I have 2 boxes box1 and box 2. box1 is way above box2 I move box2 down by 1m using moveWithCollision(). I print the before and after position on console. Everthing works as expected. But now if i turn on collision on box1 (uncomment line 21), box2 does not move !!
-
Hey guys, I need your help again. How to catch collision point (face) using moveWithCollisions? Thank you.
-
Hello, i would like to create a selector like this : http://threejs.org/examples/#webgl_interactive_voxelpainter (I know it's three.js but I don't find it with babylon) My goal is to allow the user to create a cube at the cursor position. I manage to move the red mesh which represent the cursor but i don't know how to detect the collision and stop the movement of the mesh. I tried to use moveWithCollisions but it don't work well when i move fast the pointer. Do you have an issue ? Thank you in advance
-
I've found that if I use movewithCollisions with workercollisions = false, it works great else if workerCollisions = true,,,,, movewithCollisions is not moving,,,, is there something I'm missing ? if Yes,,, please tell me how to use it thx.
-
Good afternoon, I'm trying to check intersection between 2 meshes. For that I created 2 bounding boxes. When the intersection happens, the NPC should pursuit the ship. Although, it's not working, for some reason, the NPC is behaving like it had intersedted all of the meshes in the screen at the same time (like if the bounding box had infinite size. there's part of the code. activate is called on the main scope, The example his checking the intersection between the this.boundingbox and the playermesh, but i already tried with the boundingboxship (of the player), and tried with "false" also, it doesn't work, with false doesn't detect anything at all. I also commented out all the collision stuff, including the ellipsoids, still nothing. Thanks for the help in advance. patroller.prototype.activate = function(){ var a = this.units.length - 1; console.log(this.arrived); if (this.arrived === true){ var tempx = Math.floor(Math.random()*(this.mapSize-1+1)+1); var tempz = Math.floor(Math.random()*(this.mapSize-1+1)+1); this.targetX = tempx; this.targetZ = tempz; this.arrived = false; } //estado patrol if ((this.arrived === false) && (typeof(units[a].getMesh())!=="undefined")&&(typeof(this.mesh)!=="undefined")){ //this.npcPosX = temp.getPositionX(); //this.npcPosZ = temp.getPositionZ(); this.move(this.targetX,this.targetZ); //var meshtemp = units[0]; //console.log(units[0].getMesh()); //console.log(meshtemp.mesh); for (var i=0; i<this.units.length; i++){ if (typeof(this.units[i].getMesh())!=="undefined" ){ //console.log(units[i].getMesh()); //console.log(this.mesh); //console.log(meshtemp); //console.log(this.boundingBox); //console.log(units[i].boundingBoxShip); if (this.boundingBox.intersectsMesh(this.units[i].getMesh()),true){ console.log("funciona"); this.attackedUnit = this.units[i]; //estado de perseguição this.move(this.units[i].getShipPosx(),this.units[i].getShipPosz()); var targetx = units[i].getShipPosx(); var targetz = units[i].getShipPosz(); var posix = this.getPositionX(); var posiz = this.getPositionZ(); var dx = targetx - posix; var dz = targetz - posiz; var vector = Math.sqrt(dx * dx + dz * dz); if (vector<=25){ //estado de ataque //attack (); } } if (this.armor<5){ //estado de fuga this.move(Math.floor(Math.random()*(this.mapSize-1+1)+1),Math.floor(Math.random()*(this.mapSize-1+1)+1)); } } }
-
Good afternoon, I'm trying to implement mesh collisions instead of a physics system (turns out that it costs to much in performance and i don't have the time to implement it right now), at first look it looks simpler. Although... I wen't looking at the tutorial and at dad72 example, and I'm not beeing able to implement it. I don't understand the concept behind the moveWithCollisions function and the velocity vector3. In my game I don't have a velocity var, the player point and click and the ship moves to that place. So... If i understand the concept, I may adapt it. At first, i thought.. well, maybe the function will try to calculate the mesh destiny, so I directly putted de ship X and Z coordinates on the velocity vector3 and it didn't work. I pasted a bit of the code. Notice that selectedUnit[a].setVelocity(velocity); is calling the setVelocity method, this method calls moveWithCollisions with the velocit parameter. this is part of the units class and the selectedUnit is one array of Units Thanks in advance for the help. if ((posix!==0)&&(typeof(posix)!=="undefined")&&(isNaN(posix)===false)){ if (targetx === 0){ Number(targetx); targetx = Number(posix)+1; Number(targetz); targetz = Number(posiz)+1; } camera.target = new BABYLON.Vector3(posix,0,posiz); systems[0].calculateSunDistance(camera); //calculateSunDistance(systemB1,camera); systems[1].calculateSunDistance(camera); //calculateSunDistance(systemB2,camera); dx = targetx - posix; dz = targetz - posiz; rot = Math.atan2(dx, dz); len = Math.sqrt(dx * dx + dz * dz); if (len === 0) len = 1; dx = dx / len; dz = dz / len; if (rot!==0){ posfy = rot + Math.PI; } posfx = parseFloat(selectedUnit[a].getShipPosx()) + parseFloat(dx); posfz = parseFloat(selectedUnit[a].getShipPosz()) + parseFloat(dz); shiproty = posfy; shipx = Math.round(posfx, 1); shipz = Math.round(posfz, 1); shipid = selectedUnit[a].getShipId(); selectedUnit[a].setShipPos(shipx,shipz,shiproty); ship = selectedUnit[a]; //velocity = new BABYLON.Vector3(parseFloat(Math.sin(parseFloat(shiproty))) / 1, 0.5, parseFloat(Math.cos(parseFloat(shiproty))) / 1); velocity = new BABYLON.Vector3(parseFloat(shipx), 0.5, parseFloat(shipz)); //console.log(velocity); selectedUnit[a].setVelocity(velocity);
- 19 replies
-
- movewithcollisions
- collision
-
(and 1 more)
Tagged with:
-
I'm trying get mesh.movewithcollisions working, and I'm not sure why the player sphere is partially intersecting the sphere and the plane. I have some physics in the scene, but turning them off doesn't change the result. html: http://jesseolsson.github.io/bug_movewithcollisions/ javascript: http://jesseolsson.github.io/bug_movewithcollisions/index.js
-
When an animation (scene.beginAnimation) inside of a collider, it crashes the scene. It works with a static object, but not have an object to animate.
-
Hi, When I approach the wall.... See the result in the link. I do not know to explain it. (but the collisions this product prior to contact with the wall and the character it raises) The speed is also very reduced following settings. http://www.babylonjs.com/playground/#2J98EA#14 I don't understand what happens. How to solve this problem. Is it possible to display the colliders? Thanks