Search the Community

Showing results for tags 'rotation'.

• Search By Tags

Type tags separated by commas.

Forums

• HTML5 Game Coding
• News
• Game Showcase
• Web Gaming Platform
• Coding and Game Design
• Frameworks
• Phaser 3
• Phaser 2
• Pixi.js
• Babylon.js
• Panda 2
• melonJS
• General
• General Talk
• Collaborations (un-paid)
• Jobs (Hiring and Freelance)
• Services Offered

Interests

Found 167 results

1. Get rotation of camera

I have an application where I have an FPS like camera that moves around a scene. I want to be able to use a camTo function to move the player around the scene. I have a position v3 and target v3. If I do not have a rotation value, the camera is not looking at the target. Is there a way to calculate the rotation knowing the position of the camera and the position of the target. Is my approach to this incorrect? How do I correctly move my freecamera to the correct location and ensure that it is looking at my desired target?
2. Calculate fastest side to rotate

Hello guys! Probably more a math problem than a phaser one, but still I'm breaking my head finding a solution. Maybe you can help me! Imagine I have a sprite pointing towards the direction of the red arrow. I want to make the sprite rotate slowly towards the pointer (in this image the green arrow), and to have it rotate clockwise/counter-clockwise depending on which way is faster (in this case counter-clockwise). How can I calculate if the faster way is clock/counter-clockwise, providing the sprite can be pointing wherever and the pointer could be anywhere? If I was not clear I can try to clarify better Thanks in advance!
3. Animating quaternion vs euler

Hello again I'm trying to animate between two rotations (from 0 to 45 degrees). If I use euler angles, it works fine. If I use quaternions however, it doesn't (it goes to about 20 degrees). See PG below, comment/uncomment lines 44/45. http://www.babylonjs-playground.com/#RSEYY#1 Any thoughts? EDIT: Just found out about .rotationQuaternion, seems to work now Thanks!
4. Cameras and angle limits

Hey guys! thanks for all the answers in the other topic, those helped me a lot ;). I have a doubt, how can I set a min angle and max angle for my camera rotation? because I don't want my camera to rotate 360° . What I tried is to let a little box to follow the camera and it has a collision with some walls in order to stop showing the part I don't want to. it worked but the effects are really ugly. That's is solution, as I mentioned It's has some ugly effects and is not always exact. var prevTarget= jQuery.extend(true, {}, camera.getTarget()); //OP1 scene.registerBeforeRender(function () { for(var i in objs)//the walls I mentioned if (objs[i].intersectsMesh(sphere, true) && scene.isReady()) camera.setTarget(prevTarget); prevTarget= jQuery.extend(true, {}, camera.getTarget()); }); //or //OP2 (more precise) setInterval(function(){ for(var i in objs) //the walls I mentioned if (objs[i].intersectsMesh(sphere, true) && scene.isReady()) camera.setTarget(prevTarget); prevTarget= jQuery.extend(true, {}, camera.rotation); },0.1); I hope a better way to do it, thanks guys for supporting us
5. Z axis FreeCamera rotation

Hi, I'm trying to figure out how to rotate a FreeCamera on Z axis without using a handler. In this example http://www.babylonjs-playground.com/#1CEZ5W#0, I only can rotate the camera using the handler. You can comment/uncomment the rotation lines in the renderLoop in order to see the difference. Do you understand what I want to show ?
6. Mesh Rotations

Hi Babylon Community! For the last couple of hours I have been struggling with mesh rotations, and to be honest at this moment I simply have no idea how rotations work in Babylon. I created a simple PG here http://www.babylonjs-playground.com/#LOSW9#1 Basically, I want all the colorful planes in this PG to be perpendicular to the ground (I have tried everything and it's been painful for me so far) Somebody plz help ;__;
7. Keeping sprites still

Hi all. I just started using Phaser, and I’m excited by the potential. I could use some help with some problems in this game: http://davebsoft.com/web-games/invisible-maze/ https://github.com/dcbriccetti/web-games/commit/d814fe45a655e8fc0916149156fca95cb22c7a3c#diff-ad4eb6229e24f5cc681cc10695f640ca When the player character hits the “mines” (lightning bolts), he rotates. I don’t want him to. Sometimes the mines move about “aimlessly”. I don’t want them to move (except perhaps a little when the player character bumps them). I’ve looked at several examples and read some of the source code, but I feel like I’m still sort of guessing about a lot of things. Perhaps someone could give the code a quick general review? Thanks!
8. euler to quaternion rotation issue

changing rotation from quaternion to euler resets the mesh rotation consider this http://www.babylonjs-playground.com/#ZTNIZ Here I am just rotating the cube by 45 degree around y axis. This works as expected. Now just convert the rotation to euler http://www.babylonjs-playground.com/#ZTNIZ#1 And the cube goes back to its previous rotation !!
9. no way to rotate object globaly

Hello, I read in the doc that rotation is achieved before translation, but I try to have an offsetted object rotate around the 0,0,0 axis and I cant find any way to achieve this ... usualy(with other engines) I offset the object on its local axis then simply rotate it globaly with a matrix/quaterion/rotate function I tried different combinations of these two mesh.translate(BABYLON.Axis.X, 3.0, BABYLON.Space.WORLD); //or LOCAL mesh.rotate(BABYLON.Axis.Y, 1.0, BABYLON.Space.WORLD); //or LOCAL (I wanted to rotate the object position with a quaternion, but the Quaternion lacks of regular/usual .mult(Vector) or .rotate(Vector) and anyway, it wouldn't be what I want to achieve) any idea ? thanks
10. Sprite.rotation

Hi, The post title might be a bit of a misleading one as I do not have a real problem with the code itself, but the thinking process around it. What I'm trying to accomplish is the following: aiming and shooting an object based on drag distance and drag direction, etc. When dragging the mouse I want a line to appear into the direction the object is going to be shot. I have no problem with making the line appear, shooting the object etc, but I do have a problem with the correct direction. I've been trying to accomplish what I want with the rotation property, but I'm getting nowhere I want to get at. I totally suck at explaining what I'm trying to accomplish, but the best example is the app (game) bbtan in which the aiming functionality is exactly as I'm trying to accomplish, except for the fact I want to be able to aim downwards too. In the following youtube video you can watch some gameplay of the bbtan game. https://www.youtube.com/watch?v=WISOyBzd9J0 p.s.: I'm not trying to make a copy of bbtan, yet their aiming method is what I need.
11. Mesh Box Color Changes when rotating

can anyone check this http://www.babylonjs-playground.com/#1EIE9G#0 steps to reproduce : 1st rotate around X then rotate aroung Y if you notice the color or another Box is changed cay anyone tell me why please help me I'm new hear
12. Rotation prop missing on objects loaded from object layer in a tilemap.

This is how I load the tilemap, instantiate a background layer and get the object layer for it: // preload levelgame.load.tilemap( "tilemap", "assets/levels/tilemap.json", null, Phaser.Tilemap.TILED_JSON );game.load.image( "tiles", "assets/levels/tileset.png" );var map = game.add.tilemap( 'tilemap' );map.addTilesetImage('tile-set', 'tiles');// create background layervar layer = map.createLayer( backgroundLayerName );// get objects from the object layervar levelObjects = map.objects[ objectsLayerName ];levelObjects.forEach( function( element ) { //...} );I get the position and name properties, but there is no rotation. I've made sure tiliemap.json has the rotation values for every object. I am trying to use the Arcade physics engine, could this be the reason? Thanks.
13. P2 disable body rotation from other forces

Hi there, how can I disable P2 physics rotating specific body while still be able to use body.rotation property ? I tried kinematic but it ruins collision
14. How to rotate perplexus mesh around current center of playBall (sphere mesh) ?

Hi, Here is my example. Code works so that perplexus(mesh) is rotated around it's center. With Key 1,2 around Y, with key 3,4 around X and key 5,6 aroudn Z. Can anybody help me to solve how to rotate perplexus(mesh) around current center of payBall(mesh)? http://86.58.118.110:8080/BabylonBall/Main.html if I add code var currentCenterPlayBall = perplexusRef.playBall.getBoundingInfo().boundingSphere.center; I get currentCenterPlayBall (x,y,z). How can I rotate perplexus Mesh around currentCenterPlayBall this current (x,y,z) ? switch (keycode) { // user inputs case 49: // 1 perplexusRef.perplexus.rotate(BABYLON.Axis.Y, Math.PI / +512, BABYLON.Space.LOCAL); perplexusRef.perplexus.updatePhysicsBodyPosition(); brake; case 50 : // 2 perplexusRef.perplexus.rotate(BABYLON.Axis.Y, Math.PI / -512, BABYLON.Space.LOCAL); perplexusRef.perplexus.updatePhysicsBodyPosition(); break; case 51 : // 3 perplexusRef.perplexus.rotate(BABYLON.Axis.X, Math.PI / +512, BABYLON.Space.LOCAL); perplexusRef.perplexus.updatePhysicsBodyPosition(); break; case 52 : // 4 perplexusRef.perplexus.rotate(BABYLON.Axis.X, Math.PI / -512, BABYLON.Space.LOCAL); perplexusRef.perplexus.updatePhysicsBodyPosition(); break; case 53 : // 5 perplexusRef.perplexus.rotate(BABYLON.Axis.Z, Math.PI / +512, BABYLON.Space.LOCAL); perplexusRef.perplexus.updatePhysicsBodyPosition(); break; case 54 : // 6 perplexusRef.perplexus.rotate(BABYLON.Axis.Z, Math.PI / -512, BABYLON.Space.LOCAL); perplexusRef.perplexus.updatePhysicsBodyPosition() break; Any help? greetings Any help? greetings
15. Group Rotation Clock and counter Clockwise

Hi! I'm rotating a group clockwise and counter clockwise with a button that does mygroup.rotation += 90; //for clockwise mygroup.rotation -= 90; //for counter clockwise but the group, rotated from its center, does not rotate 90 degrees... why? It rotates sometimes more or less, but never 90 degrees... Any ideas? I'm not using physics. Thanks
16. How to set mesh.rotation correctly after a previous rotation

Hi All, I'm facing a problem with rotations of boxes. Basically I need to rotate a cube by 90° around the system axes, but I noticed that when a box has a rotation set, say on x axis, if you set a rotation on z, actually you're rotating the mesh around the global system Y axis. Does rotation property refer to a coordinate system that is "local" to the mesh ? How can I calculate the correct x,y,z rotation with respect to the global axes ? Thanks in advance P.S. I have created a simple playground for this: http://babylonjs-playground.com/#NJJPP#0 If you click once on "rotat.around x" then when you click "rotat.around.z" (more than one time to notice the rotation) you will get a rotation around global Y axis. But if you only click on the same button multiple times (refreshing the page to reinitialize when you decide to change the button) the rotations are performed around the right axis.
17. Sprite rotation also changes it's position

When I change a sprite it's rotation with *.rotation, *.angle or *.pivot, it also changes the position because the center of the sprite will change. I'm making a game with a grid and it makes my sprites fall out of their tiles, how can I prevent this? Also here are some example pictures: Normal http://i.imgur.com/V8FRJ3M.png Anchor 0.5 http://i.imgur.com/xLoEpZi.png Angle 90 http://i.imgur.com/x1YtRnn.png
18. orbital shield, group or individual sprites?

Hi guys, I'm sure people have come across this before, but I'm wondering whether it would make sense to use groups for orbital sprites. I'm trying to set up a typical orbital shield using rotation, and thought it would be cool to add many sprites to the orbit. I've got it working well enough with a single sprite, but adding additional balls seems to result in them colliding immediately, gaining velocity, and spinning out of orbit. Is it even worth using a group for something like this, or would I be better off using individual sprites like in this example? Here's what I'm doing so far, and I haven't tried to add any code for collisions yet but the idea is to block enemy shots with the orbs. I'm not sure why the orbs collide with themselves in the group since they don't collide with anything else in the game yet, but I think using p2 to get collision handlers would be the next step. export class PsiBall { constructor(game, player) { this.game = game; this.player = player; this.psiballs = game.add.group(); this.addBalls(10); this.psiballs.parent = player; this.psiballs.enableBody = true; this.psiballs.physicsBodyType = Phaser.Physics.P2JS; this.psiballs.pivot.x = 5; } rotate(speed) { this.psiballs.rotation += speed; } createBall(x, y) { let ball = this.psiballs.getFirstDead(); ball.reset(x,y); } addBalls(count) { for(let i = 0; i < count; i++) { let psiball = this.psiballs.create(0, 0, 'item-57', 0, false); this.game.physics.p2.enable(psiball); psiball.scale.setTo(0.5); psiball.smoothed = false; psiball.anchor.setTo(0.5); psiball.enableBody = true; } }}

asdf
20. rotating eyes towards the camera

Right now I am trying to figure out how to make my character's eyes rotate and orient towards a camera. I am attaching my babylon file to this, but what I am hoping to do is create a lookAt function for the eyes. Is there an easy way that I can set the local rotation for the eyes so that they follow the camera, or any object in 3d space? The pivot point of the eyes is in the center of the eyes so they should rotate without a problem. I realize that the idea of the forum is to contribute to the solution as well, but I am a little lost as to where to start. Is there some information on the web that can help as well? Thanks. I attached the babylon file in case anyone wanted it. content.zip
21. FreeCamera Rotation Limit around X-Axis

Hey folks, I am using a FreeCamera and want to be able to rotate all the way around the x-axis but the rotation always stops when I look straight down. I searched the forum and the web but I couldn't find a setting to disable that. Is that a technical limitation or is it somehow possible to create a workaround? Not sure how useful a playground for that question is, but better to have on than not to http://www.babylonjs-playground.com/#22PVJH You start looking at a sphere, then look down, you will see another sphere and the ground. If you are there, you can't look down an further. I would like to be able to keep going. Like sitting in a spaceship with no real down. You know what I mean?
22. Animating the hands of a clock

I have a clock with hands for hour, minute, and second. While it is not a problem to rotate the hands according to the correct time, I am not getting the correct time. It seems like the hands are opposite where they are supposed to be. Exactly opposite. I put together a playground demo to show what I am doing. Has anyone had experience with this? This same formula was working correctly in THREE.js. http://www.babylonjs-playground.com/#1JK5E8#8 Thanks in advance
23. Is there a setRotation function?

Hello, I want to make it so that a plane mesh follows the camera (i don't want to use billboard mode for...reasons), which it wouldn't be hard to do (set rotation.y equal to camera.alpha, and it works fine) but since the plane has been previously rotated using the "lookAt" function now it uses Quaternions which i can't really grasp how they work at the moment. Is there a way to just set the rotation of a mesh to a certain value without having to use quaternions, or a way to convert a Vector3 rotation into a quaternion rotation?
24. How to use rotation but not rotate sprite?

I'm trying to create a simple game involving a fish following the pointer by replicating and modifying this code: http://gamemechanicexplorer.com/#homingmissiles-1 (BTW great site for noobs.), but the entire missile/fish rotates towards the pointer in this example, while I don't want the sprite to rotate. How can I achieve this? Also how can I add animation to the missile while it is chasing and while it is turning by 180 degrees? Any help is appreciated.
25. Object rotation problem on mobile

Hello folks, I have here a code to rotate my car object: //turnSpeed is a fraction of the car's current speed so that the car can't rotate without moving forwardturnSpeed = speed / 6000; //these conditionals are true when the buttons on the screen are touched if (rightArrowLeftIsPressed) { playerCar.rotation += turnSpeed; } if (leftArrowLeftIsPressed) { playerCar.rotation -= turnSpeed; }//if no button is pressed, the car should snap to a wind direction if it's already close to one else { if (playerCar.rotation < 0.15 && playerCar.rotation > -0.15) { playerCar.rotation = 0; } if (playerCar.rotation > (Math.PI - 0.15) || playerCar.rotation < (-Math.PI + 0.15)) { playerCar.rotation = Math.PI; } if (playerCar.rotation > -Math.PI / 2 - 0.15 && playerCar.rotation < -Math.PI / 2 + 0.15) { playerCar.rotation = -Math.PI / 2; } if (playerCar.rotation > Math.PI / 2 - 0.15 && playerCar.rotation < Math.PI / 2 + 0.15) { playerCar.rotation = Math.PI / 2; } }For some reason, pressing the rightArrowLeft button works only until the car reaches a rotation of 0, 90, 180 or 270. Then, it snaps to that direction without rotating further. The leftArrowLeft button, to rotate counterclockwise, works without any problems. Anyone have any idea why this would happen? Thanks