Search the Community
Showing results for tags 'following'.
-
Hi all, I recently started playing around with threejs and am looking for suggestions on implementing terrain following. I have a simple demo here: http://rhuno.com/tests/webgl/height/ This works to a degree, but it isn't very smooth. The box just kind of pops to a new height. My current technique just combines triangles into quads, checks to see which quad the box/player is within and then sets the box's y position to the average y of the quad's vertices. The code is below. for(var j = 0, len = geometry.faces.length; j < len; j+=2){ face1 = geometry.faces[j]; face2 = geometry.faces[j+1]; if( pos.x >= verts[face1.a].x && pos.x <= verts[face2.b].x) { if(pos.z >= verts[face1.a].z && pos.z <= verts[face2.b].z) { var avgY = verts[face1.a].y + verts[face1.b].y + verts[face1.c].y; avgY += verts[face2.a].y + verts[face2.b].y + verts[face2.c].y; targetY = avgY * 0.166 + 4.5; } }}// increase y positionif(targetY != undefined && Math.abs(targetY - pos.y) > 0.5){ if(pos.y < targetY) pos.y += 0.5; else if(pos.y > targetY) pos.y -= 0.5;} I was just wondering if anyone had any tips or good resources for a better implementation and smoother results. Cheers.
-
A friend and I are working on a platformer-fighting game using the Phaser framework and are wondering if there is anyway built in function to keep multiple sprites on the screen at the same time? We want it so that we can zoom in to the players if they are all next to each other but for the camera to zoom out if they separate (kinda like super smash bros melee).
- 2 replies
-
- camera
- phaser-camera
-
(and 3 more)
Tagged with: