Search the Community

Showing results for tags 'rotation'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

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

Found 142 results

  1. Spin a wheel and land on specific segment

    Hi All I'm quite new to Pixi (as in this is day #2), I have a simple circle divided into segments (Wheel of Fortune style). What I want to do is spin it, wait for a few seconds, slow down and stop on a specific segment, with a bit of bounce-back. By the looks of things rotation itself is fairly straightforward, but how would I go about doing this? Many Thanks
  2. Hi All, the issue I'm facing is probably trivial to solve but I couldn't find a solution. Basically I need to set the parent of a mesh (used as rotation pivot) to null after a rotation, because I need to use that pivot again for another group of meshes. I tried to use the following approach: var pos = box.getAbsolutePosition(); var rot = box.rotation; box.parent = null; box.setAbsolutePosition(pos); box.rotation = rot; but it seem to keep only the position, but not the rotation. I have created a simple playground to reproduce the problem : https://www.babylonjs-playground.com/#S13YXG#2 As you can see, when the animation is completed the bigger box returns to the original rotation. Any suggestion ? Thanks a lot in advance
  3. Is there a way to tell the back of a mesh.to.lookAt() something? For example, need object to lookAt target point in opposite direction. Any tips? Thx,
  4. Hi gang! I'm still having problems "aiming" mesh in some direction (vector). I know, I know, I should have this mastered and memorized, but, not yet. https://www.babylonjs-playground.com/#BFM7EX#24 I have TWO cones that need to be set per the direction of a spotlight. #1. The green cone (arrow1) needs its POINT aimed the same direction as the spotlight. (-1, -1, -1) #2. The curiously black-sided blue cone (spotcone) needs its WIDE-END... aimed in same direction as spotlight. I added the spotlight so I could "see" a -1, -1, -1 direction... and I know spotlights do direction correctly. I could "steal" example code from spotlight direction-setting code, but that direction-setting code... rotates no mesh. It only creates light directions, and lights aren't mesh. The spotlight is positioned where the two cones meet. And again, the spot is aimed -1, -1, -1, and it appears to be using that direction properly. Feel free to turn-off animation in lines 101-102. They are there only to prove that I have my pivot points set correctly for the two types of cones. There are two un-coded important functions. Lines 73-75 to set arrow1 aiming, and lines 80-82 to set spotcone aiming. Lines 95 and 96 are where both do-nothing functions are called-from. Can someone please assist me in coding arrow.setDirection(direction) [line 73] and spotcone.setDirection(direction) [line 80] ? That would be great. Currently, cam is aiming +z. We already knew that, because the -1, -1, -1 spotlight direction... is down, left, and backwards toward the cam. Thanks again for any/all assistance/consideration.
  5. Tracing a rotating point

    Hi I'm still pretty new to phaser, and I've looked through the docs and a few examples, but still haven't found a solution to my problem. So, i have a sprite that is rotating around a set anchor, and I want to get the x and y coordinates of a specific point on this sprite. I could just do it with trigonometry and whatever, but I'm thinking that there has to be an easier way using phaser. Thanks in advance.
  6. Hello It is possible turn off parent rotation ? var box = BABYLON.MeshBuilder.CreateBox("box1", 1, scene); var sphere = BABYLON.MeshBuilder.CreateSphere("sphere1", 1, scene); box.parent = sphere;
  7. mesh.lookAt I want to get x, y, z after rotation What should I do? Mesh.rotation.x gets null
  8. Hi all, I've been banging my head off the desk for days now and can't figure out how to go about accomplishing this. I've gotten to the point of being able to scale or rotate around a random pivot point, but only once, I need to be able to do it multiple times in a row. For example (in the GIF attached); I need to scale the box across the red line as the pivot point, and then scale the box along the blue line as the pivot point and then finally rotate the box around the green dot as the pivot point. I can do each step individually just fine, but the chaining together completely breaks as I can't figure out how to set the pivot point on the already manipulated sprite properly. Does anyone have any ideas on how to accomplish this? I really need to get this working asap and I'm at the end of my rope. Thanks.
  9. I try something pretty easy (I think) but I cant make it work. The want that the faces are aligned in their direction between two world space Vector3. The position on the screenshot is not correct but that's not the problem. I tried it with lookAt for the mesh and also played a bit around with RotationFromAxis from this example http://www.babylonjs-playground.com/#1QM99D#6 But its always not correct rotated, correct would it be when they are aligned along the edge between the two vertices where currently the feces are placed. Any suggestions?
  10. When adding a rectangle to a p2 body you have the option to specify a rotation in radians for the shape which it appears is just passed directly on to the p2 shape constructor (hence the need for it to be in radians instead of degrees as are used elsewhere in Phaser). I find that if I use any value other than 0 for a rotation, the shape is properly rotated however drawing of the body via the debug parameter ignores the rotation. Here is a quick codepen illustrating the bug. The character should have a long protrusion coming out the bottom achieved with a rotated rectangle. The physics collision seems to indicate that the rotation has occurred correctly, however the debug shape is not drawn rotated. Notice that he appears to sit a little ways off the ground due to the un-rotated debug visualization of the shape. It seems to me this must be a bug (or maybe a limitation of the debugbody drawing system) but I thought I would post here first for thoughts. I will likely dig in and see if I can find a fix / workaround for this. Phaser P2 DebugBody rotation bug (codepen)
  11. Hey guys, I'm thinking there's a really simple answer to this, but I'm currently blanking on it. Basically, I'm trying to position/rotate a cylinder such that it is perpendicular to a given facet. Here's the PG: https://www.babylonjs-playground.com/#U8ZVF8 It looks like it works for facets on part of the sphere (maybe?), but there's clearly something I'm missing. Thanks in advance!
  12. I'm getting the freecamera values but they are radians and if i continue rotate they increase more than 6.28 or less than -6.28 . So whay i do for conversion actually is: (camera.rotation.y*360)/6.28 So i get the camera values as i want. But i can figure how fix the infinite rotation value thing, maybe there is some function or something i missing to avoid that?
  13. I have a box and a ground with physicsImpostor, how can I keep the rotation of the ground up to date with the rotation of the box. here is the playground https://www.babylonjs-playground.com/#T310H5 If I use "ground.rotation = box.rotation", then the ground rotate but the box do not. If I use "ground.rotation.x = box.rotation.x", then the ground will keep rotating.
  14. angleToPointer on child sprite

    Hi guys, I'm trying to rotate a player's arm (anchored at the shoulder) to the mouse pointer using angleToPointer() method for aiming. I have a player sprite and a frontArm sprite. angleToPointer works as expected until I make the frontArm sprite a child of the player sprite. When I do this, the frontArm sprite will get stuck at certain points and won't rotate any further. I'm a complete newbie to Phaser and game dev so any help would be appreciated. I'll put my code below: create: function() { this.background = this.game.add.sprite(0, 0, 'background'); this.game.physics.startSystem(Phaser.Physics.ARCADE); this.player = this.game.add.sprite(200, 500, 'player', 'Fire Marshall Main_00025'); this.game.physics.arcade.enable(this.player); this.player.anchor.setTo(0.5); this.frontArm = this.player.addChild(this.game.make.sprite(-10, -240, 'frontArm')); this.frontArm.anchor.setTo(0.48, 0.30); this.game.physics.arcade.enable(this.frontArm); //walk animation this.player.animations.add('walkright', Phaser.Animation.generateFrameNames('Fire Marshall Main_', 0, 24,'', 5), 24, true, false); this.player.animations.add('walkleft', Phaser.Animation.generateFrameNames('Fire Marshall Main_', 24, 0,'', 5), 24, true, false); cursors = this.game.input.keyboard.createCursorKeys(); }, update: function() { //player walk movement this.player.body.velocity.x = 0; if (cursors.right.isDown) { this.player.body.velocity.x = 150; this.player.animations.play('walkright'); }else if (cursors.left.isDown){ this.player.body.velocity.x = -150; this. player.animations.play('walkleft'); }else { this.player.animations.stop(); this.player.frame = 25; } this.frontArm.rotation = this.game.physics.arcade.angleToPointer(this.frontArm); }
  15. Freeze Rotation

    Hey Guys, I have an object parented to a modified ArcRotateCamera. The Camera can pan left and right. I want my object to move left and right with the camera but not rotate when the camera rotates around its target. Is there any way to freeze the rotations of a mesh so that it does not rotate with its parent?
  16. Hi, We have a project where there's a need to get absoluteRotation and / or absoluteRotationQuaternion. Is there a need somewhere so a pull request about this is possible ? If so, is it wise to compute it here https://github.com/BabylonJS/Babylon.js/blob/88145e1d19e13c88afd09c63a474d0af15e0d7a1/src/Mesh/babylon.abstractMesh.ts#L1312 By adding _absoluteRotation and _absoluteRotationQuaternion private properties and this._worldMatrix.getRotationMatrixToRef(Tmp.Matrix[0]); BABYLON.Quaternion.FromRotationMatrixToRef(Tmp.Matrix[0], this._absoluteRotationQuaternion); if (!this.rotationQuaternion) { this._absoluteRotationQuaternion.toEulerAnglesToRef(this._absoluteRotation); } Or should it be only done in a getAbsoluteRotation method to avoid the overhead of computing it every time computeWorldMatrix is invoked ? (note : what's the usage for this kind of question ? using the forum, GitHub issues or directly submitting a PR on GitHub ?) Thanks a lot and have a nice day !
  17. Animation Question

    Hey Everyone! Still working with my same project looking at the depth perspectives and minor animations, I'm either looking for a page which is better structured than babylons own help page - Find it very unhelpful and vague personally, or some suggestions from everyone on here. I am looking to see if i can create the animation affect to give a sense of depth to the build, the best online example effect of what I mean is here: https://www.g-star.com/en_gb/raw - You can see as you go across the team, you are able to see the effect i'm trying to describe and aspire to build, as you look for example at Pharrell Williams sat on the stool and the tall guy with glasses behind him, as you go from the leftmost view to rightmost. If anyone can help me with this I would be very appreciative. as I am currently struggling to find a start point, I will attach a playground of my current project to see what I currently have running and if possible could even demo the effect i'm after using it would be great! Please note that the FOV I wish to use is 0.30, but is set to 1 in the example as the texture error boxes are rather big. Playground: https://playground.babylonjs.com/#0RDNN7 Thanks everyone! Mezz
  18. I just want to know how to set it so my camera rotation wont look all the way up and down id like it to look about 10% above and below where my content is, there is a link to the playground at the end. I have tried setting beta/radius/alpha limits, I have tried inertia, I have tried the height map stuff, I have tried everything I can think of or find in the documents. https://www.babylonjs-playground.com/#AEXWGL#2
  19. Hi everyone! I have actually a problem which is quite stupid but I really need help to solve it: I have a sphere (position 0,0,0) on which I want to "put" a mesh. I have a ray coming from the center on the sphere to a point somewhere in space, and want to put the mesh on the sphere surface, oriented to the center of the sphere, as if the sphere was a planet. I don't find anything in order to rotate a mesh from a ray in Babylon, and all the tries I do with a trigonometric approach aren't satisfying… Here is the code doing that: http://www.babylonjs-playground.com/#C1M3C7 Thanks for your help!
  20. Hi all, is it possible to disable camera movement except rotation, so as to get a streetview-like camera ? I prepare a playground : http://www.babylonjs-playground.com/#K4TSQD Here we have a sphere, with a spherical texture mapped on it, camera is placed on its center, and all we want for now it that user can't move, but still can look around. Is their a way to override movement settings, or other tweaks ? Thanks for helping
  21. Is it possible to get the absolute rotation of a child mesh, in the same way it is possible to get the absolute position of a child mesh via mesh.getAbsolutePosition?
  22. So, making a card game. Im trying to spread the cards in the players hand out, essentially along an upside down, elongated U pattern (basically, the reverse of how you would hold playing cards in real life. - But reverse or not, the task is pretty much the same, fanning the cards and rotating, evenly distributing amongst a finite amount of space. - originally I tried solving it via a super janky function. Then I realized: if I draw the shape I am trying to align the objects around, in theory I could get the coordinates of various points of the shape and then essentially assign each card in hand the distributed coordinates. - So I guess I'm wondering, is there an easy way to do this? I've finally set up a playground to replicate the basic structure of my scene. Sidenote: I am trying to replicate as close as I can to what I actually have, because what I actually have is less than ideal (im having various issues with text rendering, positioning, and other things, that I think may be a scene structure type of issue. (So if you see something stupid that I am doing or that could be improved I'm all ears.) - Anyways here's scene 1, with what I am currently doing with the hand (the rotation is causing the middle cards to appear higher than the cards on the ends, which is the opposite of what I want). https://playground.babylonjs.com/#ZDWG7D#8 Instead I would rather align the bottoms of the cards to the bottom of the half ovalish shape seen here (the player hand shape object) https://playground.babylonjs.com/#H1D1PB But I have been struggling to figure out how to do so. Is there a technique to do this easily? Or anyone have any suggestions? Any help much appreciated as always. P.S. I read https://doc.babylonjs.com/overviews/how_rotations_and_translations_work which sounded like it might lead me to what I am trying to do, but it's still a little advanced for me, and ultimately, the starting point would be knowing how to split up the path of the oval shape into positions, which I am failing to figure out. (and IDK if there is a built in, easier way to align the planes to the bottom of the oval).
  23. Hello, This may be a simple answer. A cube is rotating around the x axis with .addRotation(). GOAL: detect when cube is flat on top, with z axis, to stop animation. So what are best ways to measure Quaternion rotation progress? And then stop the animation? Thanks much,
  24. Image Angle/Rotation Wrong????

    Hello fellow HTML5 Game Devs. I have an interesting problem I am testing out some controls and different schemes for my game. I have an image of a fighter. It uses the arcade physics mode. When I press the UP arrow, it goes right.... Code: var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); function preload() { game.load.image('background','../assets/images/deep-space.jpg'); game.load.image('fighter','../assets/images/Human-Fighter.png'); } var player; function create() { game.add.tileSprite(0, 0, 1920, 1920, 'background'); game.world.setBounds(0, 0, 1920, 1920); game.physics.startSystem(Phaser.Physics.ARCADE); player = game.add.sprite(game.world.centerX, game.world.centerY, 'fighter'); player.anchor.set(0.5, 0.5); game.physics.arcade.enable(player); // Notice that the sprite doesn't have any momentum at all, // it's all just set by the camera follow type. // 0.1 is the amount of linear interpolation to use. // The smaller the value, the smooth the camera (and the longer it takes to catch up) game.camera.follow(player, Phaser.Camera.FOLLOW_LOCKON, 0.1, 0.1); } function update() { player.body.velocity.x = 0; player.body.velocity.y = 0; player.body.angularVelocity = 0; if (game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) { player.body.angularVelocity = -200; } else if (game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) { player.body.angularVelocity = 200; } if (game.input.keyboard.isDown(Phaser.Keyboard.UP)) { game.physics.arcade.velocityFromAngle(player.angle, 300, player.body.velocity); } } function render() { } If you can help, it would be greatly appreciated! Thanks!
  25. Hi @all, I have a question about the rotation again. This time its also about the lock joint. I had a similar question in the past without lock joint here: http://www.html5gamedevs.com/topic/29158-solved-rotate-player-correct-on-rotating-platform/#comment-168011 I want the same as last time, but now with lock joint. I prepared a playground: http://playground.babylonjs.com/#7CPXT#2 [In this PG you can rotate the platform with key v, b, and n. The player can rotate with the mouse (drag&drop)] Without the lock joint the behavior is like I want, but for many reasons I need this behavior also with the lock joint. The problem is, the player rotates in a strange circle on the ground. I mean the player changes his position on rotation too. How can I rotate it right?