Search the Community

Showing results for tags 'camera'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 253 results

  1. Hi guys! I'm doing a 2D game with tiled map and I've run into a problem. When the group of objects (map layer and unit sprites) scaled, and camera is focused on sprite (by following with lerp), camera.view, or autoCull (or something else) gets some offset lag But all works fine with image map. You can uncomment the /* image map */ section in 'create' tab to check it out. Dont forget to comment the /* tile map */ section Just look: Buttons: LEFT ARROW - center camera on unit1 and scale group to 1.2 (if not zoomed); RIGHT ARROW - center camera on unit2 and scale group to 1.2 (if not zoomed); UP ARROW - unzoom (set group scale to 1); Spent last two days to fix this out, but have no more ideas.
  2. Hi Guys can sombody helpme to make the VR camera follow the spline ? I try parenting the camera into a mesh that folllows the spline and the camera still on the ground. I change the camera But I can see yet why its not updating the position here is my // Target Cam // VR CAMERA INSTEAD***************************************************************************** var targetCam = new BABYLON.VRDeviceOrientationArcRotateCamera("tcam", camera.position, scene); // var targetCam = new BABYLON.TargetCamera("tcam", camera.position, scene); targetCam.setTarget(points[t]); scene.activeCamera = targetCam; var target = BABYLON.Vector3.Zero(); // animation scene.registerBeforeRender(function() { //followCam._computeViewMatrix(); points[i].addToRef(curvect.scale(k / step), pos); points[j].addToRef(nextvect.scale(k / step), target); pos.addInPlace(norms[i]); targetCam.position = pos; targetCam.setTarget(target); targetCam.getViewMatrix(); //wagon.position = pos; //wagon.rotation = rot; k++; // next segment if (k == step) { i = (i + 1) % lg; j = (i + 1) % lg; t = (i + dt) % lg; rot = BABYLON.Vector3.RotationFromAxis(tgts[i], norms[i], binorms[i]); points[j].subtractToRef(points[i], curvect); points[t].subtractToRef(points[j], nextvect); //curvect.normalize(); //nextvect.normalize(); k = 0; } }); return scene;
  3. I'm working on a game project where I want to be able to switch between two "dimensions" in the same world. I though the easiest way to do this was to have a keyboard event, which toggles sprites' visibility when pressed. This works fine, however, when the visibility is toggled off, and I move the character (and thus, the camera), the sprites seem to be keeping their position relative to the camera, and not the world. Which means that when I toggle the visibility on again, the sprites have moved from their original position relative to the world, but are in the same position relative to the camera. For example, if a sprite is off-camera while invisible and I move the character, the sprite gets pushed off the stage, and can't get back (because it falls down below the ground). How do I stop this from happening? How can I "lock" them in place while visible? I read that the sprites are not being rendered when visible=false, so should I be using some other method of hiding them? Here is my relevant code for the keyboard event: skey =; skey.onDown.add(this.sPressed,this); Here is the method sPressed: sPressed: function(key) { if (baddie.visible) baddie.visible = false; else baddie.visible = true; if (stars.visible) stars.visible = false; else stars.visible = true; } And here is how I make the camera follow the character sprite: = player.body.x-200; I tried changing to camera.follow, and camera.focusOnXY, and that changed nothing. I have tried googling, and can't find anything relevant to my problem.
  4. How is it possible to make a mesh or sprite (in)visible for just one of two active cameras?
  5. Hi Again, Let me explain what I'm trying to do first: I want a panel of 3D objects which line up along the left-hand side of the canvas/viewport. I'm trying to create an object factory of sorts. The user will click and drag objects from the object factory into the scene proper, the code will clone the selected object when this occurs. I'm using two scenes for this, one is the main scene, with a ground and control-enabled camera receiving the clones and accumulating state; and another scene, for the factory, that is essentially static but has a camera and lights and meshes (the factory prototypes). As I've said, I want this factory to be arrayed down the left-hand side of the screen. If I choose just any position for the factory objects, they will go into and out of scope when the canvas aspect ratio changes. So I want to be able to calculate a ray which vertically cuts the camera's left-hand viewing-frustum plane, say somewhere in the middle, parallel to the near and far edges. I think this should be a vertical slice, abutting the left edge of the viewport. Here's how I tried to do it: First, I tried using getFrustumPlanes. But the planes it gave me were oddly skewed. When I generated geometric planes for each of the six, for instance, they did not form a convex solid. And even when I mentally tried to figure out which plane was which part of the frustum, I just couldn't make sense of the numbers. I would have expected 2 along each camera-centric axis (e.g. + & - along X, + & - along Y, + and - along Z--I setup a straight-on camera to help in understanding the numbers to no avail). Next, I tried a few of the unproject methods. I think these methods should have converted a 2D point on the screen to a 3D point (or ray) in the world. I read through many posts on this site to use what I thought were the best values for the camera's projection matrix, world matrix (identity), etc.... Never got anything even close to good numbers. Mostly they were NaN until I saw one post which accessed maxima from the engine. But when I positioned my mesh (using a sphere) at the returned 3D vector, it always seemed to go to the same, incorrect place (irrespective of my choice for 2D starting point). Next, I successfully wrote an iterative algorithm which used many of the same transformation matrices along with project. This way, I would choose a 3D point, test where it was in 2D, and knowing the fixed orientation of the camera, choose another 3D point which projected closer to the 2D point for which I was aiming, etc.... Sort of like a newton's method for iteratively approaching the correct value that unproject should give me in fixed time. OK, I can do it, but I want to do it correctly. So my last attempt, for which I have a playground, uses: createPickingRayInCameraSpace. I think this should give me a ray which looks like a point, but really rides the intersection of the left and top viewing-frustum planes (because I choose 0,0). However it does not. Playground demo: Please help. I don't care if I use any of these methods. Is there a better way? Should I be using the aspect ratio directly? Should I just do my own matrix math? Thanks, Ken
  6. Hello there, I'm new around here and also newbie using Phaser. I have only coded turn-based games and I recently learnt how to make classic 2D platform games with Phaser (which is incredibly easier than I thought). I'm interested on develop a tennis game. Watching some old NES tennis game, every tennis game use a vertical camera with some perspective which makes appear the closer half of the court bigger than the other one, does anyone knows how to approach that kind of camera/perspective? Thank you!
  7. Silly title, I know. I'm not sure how to achieve this, and I'm sure a PG is not necessary, if this functionality actually exists. Imagine the simple and common version of a FPS-setup. You have a camera, and a mesh or more in front of this camera, usually a couple of hands and a gun of some sorts. Now, when I hit a wall face-first, part of the hands/gun model will clip through the wall, and we sure don't want that to happen. Is there some way to always render the hands/gun models in front of everything else, igoring depth? I looked at z-index, renderingGroups and masks without luck.
  8. For the life of me, I can't find a setting which adjusts camera movements with current frame rate (automatically adjusting speed, inertia, turn rate). Camera which either warps or bogs down depending on where you look at is simply unacceptable in any application, let alone games. Maybe it's too obvious but in any case I need some help here.
  9. Greetings, When searching for example/questions on how to do multiple cameras in Phaser, I came up with only one answer: using multiple Phaser instances. That was not how I wanted things to be done, so I made my own variant on it (which I saw Rich made a comment about on how it could be done) with a RenderTexture. I made a repository on GitHub containing a (fairly) heavily commented example on how things could be done this way, plus a live example. I'm honestly not sure about performance, but I can't imagine it would be worse than having multiple instances of Phaser. Look through the example, clone the repository and modify it to your heart's content, and if you have any questions, I'll do my best to answer them. This example was tested with Phaser CE 2.7.3 -MikauSchekzen
  10. I have a sidescroller world in which the camera always moves to the right at the same pace. It forces the user to move along with it, because the player cannot move outside of the camera bounds. I have tried doing it like this:, 0, +, - 60); in my update function and this works well enough for the left side of the camera but not the right. WHen I set the world width to - 1, the camera can no longer move but the bounds do work. Does anybody have an idea of what I am doing wrong?Best regards, Jur
  11. Hello, Sorry if the question has already been answered. I'm a very junior developper so go easy on me I would like to interact within a mesh depending on the zoom of the camera Here is the playground Imagine when I get closer to a box, this one just explode or disappeared to show some boxes into it. Thanx for your help Jessica
  12. Could anyone please help me by advising on how do we set the camera view angle to the cavas using babylonjs?
  13. I'd like to roll the camera (UniversalCamera) (rotate about the z-axis), but... There is no cameraRotation.z property. The rotation property has no effect. Changing the upVector "works", but input control is applied as though the camera isn't rotated. Making the camera a child then rotating the parent works (so far), but seems overly clunky. Is there an easy, elegant way of rotating the camera about the z-axis? TIA
  14. I'm writing an FPS (Asteroids in 3D) and need to change the input mapping and some of the behaviour of the camera (currently Universal Camera). 1. rotate left and right (about the y-axis) instead of move - it does this for the mouse, but not keys 2. when rotating tilt into the direction of roatation - to emphasise the motion and give a "swooping" feel 3. control key sensitivity Are these behaviours / properties directly configurable? Or do I need to subclass a new camera type, or develop a different input control mechanism?
  15. Hi @all, I have a new Demo with strange camera behavior: In the Demo is one player again (green box). The player has two children: the camera and a red box. The red box is the view direction of the player. You can move the player with WASD and the camera with the arrowkeys. Now the Problem: You can rotate the player body by pressing the R key. I rotate also the camera, but the camera.getTarget() is very wrong. You can check it by moving around with the camera after some rotations. Similar problem if I dont rotate the camera. I want the vector of the camera view direction if I use camera.getTarget(), like i get if there is still no rotation.
  16. This is bugging me. How can I check meshes in a camera frustrum?
  17. I want to make my camera follow an object, but I also need the ability to look around, the only thing I need at the moment is the camera rotation quaterion or matrix. Is it possible to calculate it somehow? If I had Z vector of camera I could just move camera back by Z vector times n from player and it would work well. If there is a topic about it leave a link below.
  18. Hello everyone, I am pretty new to the Pixi.js so I'm seeking advice from community on what is the best approach to have easy and efficient camera. Basically what I want is to have two main containers in the scene: The first one to represent the game world. Since world can be quite big, the camera is required here to show only small portion of the world. The second container to display all GUI elements, such as player healthbar, menus, scores etc. Since this container will always be the size of the viewport, no camera is required here. I looked at how camera is implemented in (which uses Pixi.js as a graphical engine) and it seems that all they do is just move "root" container in the direction opposite to camera movement (and scale it to represent camera zoom in/out). While this approach works, it has two issues: It seems quite inefficient to move root container, since this will cause recalculation of transfom of all the objects in the scene tree. I would also like to be able to "flip" the Y-axis of default Pixi's coordinate system (i.e. I want Y-axis to be pointing up like in conventional Cartesian coordinate system, not down). Unfortunately, I don't see an easy way to achieve this with this camera approach. I think the better way would be to modify projection matrix before rendering "world" container, i.e.: set projection matrix according to current camera position / zoom render world container set projection matrix for rendering GUI container render GUI Does this look like a sensible approach? How can I achieve something like this with Pixi? Thanks for advice!
  19. I am having an issue where the movement of the camera will make certain meshes disappear. The disappearing meshes are consistent, in that they are the same ones that disappear. This issue seems to happen only with the binary version. I made a playground where you can see this happening. All you need to do to see the behavior is walk forward with the up arrow. As you move forward you will see the frame in the warehouse disappear. Has anyone come across this issue before?
  20. Hi, I implemented a two finger zoom using the propierty to zoom the game. I also implemented a drag functionality using and propierties. But now I need to add static floating sprites, such that they are always in the same position on the screen regardless the zoom or the drag movement. But when I add them as sprites (game.add.sprite) they are affected by the camera propierties (x,y,scale). I read this and set fixedToCamera to true, it works partially, the (x,y) is static, but the when I zoom in (increase the size of the floating sprites also increases. Is there any way I could add sprites that are not dependent on the camera? Thanks!
  21. Hey guys, I'm playing around with Babylon a little bit and the posibilities are amazing! Maybe a little to much at the beginning. This question maybe sounds silly for you but I still hope you can and will help me. I tried to stop the camera zoom by mouseWheel but I want to keep the rotation but nothing I'm doing is working. When I do this:, false, true) I can zoom with the wheel and rotate with the keyboard and the wheel. If I don't have this line I can't zoom but of course don't rotate either. Is there a line I have to add or a parameter I need to set to false? I'm thankful for every suggestion. Google wasn't much of a help. Thanks. Jay
  22. Hi all, I am using Universal Camera and I would like to improve differents features of it. This is the definition of my camera: var camera = new BABYLON.UniversalCamera("universalCamera", new BABYLON.Vector3(600, 200, -500), scene); camera.setTarget(new BABYLON.Vector3(0,0,0)); camera.speed = 1.5; camera.checkCollisions = true; camera.ellipsoid = new BABYLON.Vector3(1, 1, 1); camera.attachControl(canvas); The first question is about collisions. When I move arround the scene and I go to some building of, all the collisions are calculated and my camera is very slow. Are there any way to optimice this operation? When I am near of the different elements of my scene the movement of camera is very bad. The second question is relative to control of camera. I want change the arrow keys to "a","s","d" and "w". Do you know if is it possible? Thanks
  23. Hi all, I am using new UniversalCamera to allow access of application web from pc or mobile devices. However It doesnt work so good. I have been testing example of @davrous and It is perfect!. Maybe I need to reprograme some tips of this camera. Now I can only turn camera in my tablet but i cant move. The version of BabylonJS that I am using is v 2.6 alpha Params of my camera: var camera = new BABYLON.UniversalCamera("universalCamera", new BABYLON.Vector3(600, 200, -500), scene); camera.setTarget(new BABYLON.Vector3(0,0,0)); camera.speed = 5; camera.checkCollisions = true; camera.ellipsoid = new BABYLON.Vector3(2, 3, 2); camera.attachControl(canvas); Thanks you very much!!!
  24. Hi all, I want change between differents camera depends on the devices. I am developing an aplicaton web in BabylonJS and I must to define FPSCamera and TouchCamera. When this web is loaded at mobile device I have to activate the touch camera and if I visit it from pc I use FPSCamera. Do you know the way to manage it? Thanks!
  25. Hi there, I'm trying to zoom out the entire game world from the center.. unfortunately I see no method for the camera for zooming out so I'm scaling the directly with, 0.5);Unfortunately, this scales around the top left of the screen. I've tried setting the anchor on the as well as the pivot to the center of the world or the center of the stage to no avail. Is it possible to achieve what I'm trying to do? Thanks for any thoughts - Nick