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. Rotation issue

Hello ! There are something i don't understand regarding mesh rotation. 1) i find the y positive rotation wrong but maybe it's because the basis is indirect. 2) when i rotate a mesh, does its rotation axis also turn? Here is an example : http://www.babylonjs.com/playground/#XXH6D#5 There are 4 boxes : box1.rotation = (0,0,0) box2.rotation = (0,0,0) box3.rotation = (PI/2,0,0) box4.rotation = (PI/2,0,0) in the render loop box1.rotation.z += 0.01 box2.rotation.y += 0.01 box3.rotation.z += 0.01 box4.rotation.y += 0.01 there is no problem for box1 and box2 (even if i think that box2 should turn in the other way) but box3 and box4 are turning on the same axis in opposite way. I don't understand why. Thank you
2. Initial rotation on physics-enabled objects

I'm getting up-to-speed on developing with Babylon.js and I'm having a problem with physics simulations and initial rotation on a mesh: You'll notice that the box and the ball bounce off the air above the "ground." My expectation is that both the box and the ball would land on the surface of the ground. It works as expected if there is no initial rotation. The greater the rotation, the more obvious the problem. Here's how I'm rotating the ground: var ground = BABYLON.Mesh.CreateBox("ground", 10, scene);ground.rotate(BABYLON.Axis.Z, .3, BABYLON.Space.LOCAL);ground.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {mass:0, friction:0.5, restitution: 0.4});If it helps, here's all the code I'm using to create the scene: var createPrototypeScene = function(engine) {var scene = new BABYLON.Scene(engine);var camera = new BABYLON.FreeCamera("Camera", new BABYLON.Vector3(0, 10, -40), scene);var light0 = new BABYLON.DirectionalLight("Omni", new BABYLON.Vector3(-2, -5, 2), scene);var light1 = new BABYLON.PointLight("Omni", new BABYLON.Vector3(2, -5, -2), scene);camera.setTarget(new BABYLON.Vector3(0, 0, 0));scene.enablePhysics(null, new BABYLON.CannonJSPlugin());// Create the groundvar ground = BABYLON.Mesh.CreateBox("ground", 10, scene);ground.rotate(BABYLON.Axis.Z, .3, BABYLON.Space.LOCAL);ground.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {mass:0, friction:0.5, restitution: 0.4});// Create the ballvar ball = BABYLON.Mesh.CreateSphere("ball", 16, 1, scene);ball.material = new BABYLON.StandardMaterial("ball", scene);ball.material.wireframe = true;ball.position = new BABYLON.Vector3(3, 20, 0);ball.setPhysicsState(BABYLON.PhysicsEngine.SphereImpostor, { mass: 5 });var box = BABYLON.Mesh.CreateBox("box", 3, scene);box.position = new BABYLON.Vector3(0, 15, 0);box.setPhysicsState(BABYLON.PhysicsEngine.BoxImpostor, {mass: 1});return scene;}Thanks!
3. 3DS Max Animated Mesh - No Modifiers

Animated mesh exported from 3DS Max 2013 using the babylon exporter. Please see the link: Adjusting the scale, rotation, and position doesn't get applied to the actual mesh. Babylon Model Files: Max Scene: BABYLON.SceneLoader.ImportMesh("", "../Models/Monsters/", "Boss_Pukui.babylon", scene, function (mapZone, particleSystems, skeletons) { mapZone[0].rotationQuaternion = null; mapZone[0].scaling = new BABYLON.Vector3(0.0005, 0.0005, 0.0005); mapZone[0].rotation = new BABYLON.Vector3(0, -3.141593, 0.000000); mapZone[0].position = new BABYLON.Vector3(-104.0314, 4.3437, -14.2259); } );
4. Cursor on the center of the canvas

Hello ! I'm trying to set a mesh at the center of my canvas while using a free camera, but I have difficulties. Considering that it's a mandatory feature in fps games, I thought that I may have a response using babylon js transformations classes, and camera worldMatrix and viewMatrix. Thank you in advance !
5. Rotating a sprite towards the pointer

Hello. I'm trying to follow http://gamemechanicexplorer.com/#homingmissiles-1 but my missiles end up pointing in the wrong direction all the time. So I simplified and removed basically everything but the rotation of the bullet. But even with a centered stationary bullet it ends up facing in another direction than where the pointer is. Missile.prototype.update = function() { var targetAngle = this.game.math.angleBetween( this.x, this.y, this.game.input.activePointer.x, this.game.input.activePointer.y ); this.rotation = targetAngle;}; I'm using 2.0.3 Any thoughts on what might be wrong here?
6. Rotating sprite causes P2 collision fail [SOLUTION]

Hey all, Just a quick heads up to share an odd solution to a problem that had me tearing my head out for a couple of days, thought it may come in handy for anyone else in the same boat. While working on a game where I was using P2 physics to detect a collision event between 2 physics bodies, I found that whenever the target sprite was rotated further than a certain amount all of my collision events would silently fail. I spent AGES trying different collision methods and none of them worked, when trying to implement a hack-ish workaround that I found on the forums (can't remember where) I realised that my collisions were now working fine, even though the method I was using returned something to the effect of "this doesn't work". Long story short - I found that by resetting a physics body's AABB data after every change in rotation made the collision events work again: //attackingThing.body.onBeginContact.add(reportSomething, this);//function rotateThing() { // thing.rotation += 1; // reportSomething fails unless you do this thing.body.data.updateAABB();}If anyone can enlighten me as to what/why/how this works, that'd be awesome. Phase on, dudes! OFM
7. Rotate Sprite Body along with Sprite angle

Hi there!! How to rotate Physics.Arcade.body? I've tried set the Physics.Arcade.Body.rotation(after set the allowRotation to true) to be equal to te sprite angle, but, nothing happends...
8. HTML5 Wrong Mouse Coordinate with transform rotation DIV

I want to make a game, when you click on target, the DIV append an image in it, When i click on the face, you can see that the DIV append a bullet image, which is good. but when you click on the right arm, the position of the bullet is wrong. it's because the arm is transform: rotate(25deg); with CSS3. this is my screenshot http://i.imgur.com/oZ5VnD6.png How can i determine the right position of the bullets when i click on the arm ? thank you
9. How to enable AABB in P2 physics

Hi there, I was just wondering if it's possible to lock the rotation of a body in p2, so it would behave like it would in arcade physics. Or is it possible to mix and match physics bodies between engines? Sorry, kinda new at this. Thank you in advance!
10. Rotating and changing position of meshes with physics

Hi! I have problems changing the rotation and position of meshes when i have added physics to them. I have taken a look at the tutorial (https://github.com/BabylonJS/Babylon.js/wiki/How-to-handle-rotations-and-translations) but still haven't found a solution. I have manage to change the rotation and position before i have added physics to the mesh but i would rather change the rotation and position without removing and adding the mesh every time i want to change it's position and rotation. I think the problem is that i don't manage to get these two function to work. mesh.rotate(BABYLON.Axis.X, 1.0, BABYLON.Space.LOCAL);mesh.translate(BABYLON.Axis.X, 1.0, BABYLON.Space.WORLD); Saying that property.X is undefined. Any suggestions and comments are more then welcome!

Hi, I'm tring to port an old game to 2.0 and I can't find the body.allowrotation for Arcade Physicsm do I need to change the physics engine to rotate my sprite body ?
12. Constant circular motion - falls slightly out of circle at end of each rotation

So I'm currently trying to make a sprite that just moves around in a circle forever. I was using the example found here: http://examples.phaser.io/_site/view_full.html?d=physics&f=angular+velocity.js&t=angular%20velocity as a base. My code for creating said sprites looks like this: @map.createFromObjects 'PlatformLayer', 45, 'platforms', 0, true, false, @circPlatforms @circPlatforms.setAll 'body.allowGravity', false @circPlatforms.setAll 'body.immovable', true @circPlatforms.forEach ((platform) => platform.radius = (+platform.radius or 1) platform.rotAngle = +platform.rotAngle or 0 @game.time.events.loop 1, ((platform) => platform.body.velocity.x = 0 platform.body.velocity.y = 0 @game.physics.velocityFromAngle platform.rotAngle, platform.radius*32, platform.body.velocity platform.rotAngle = ++platform.rotAngle % 360 ), @, platform ), @In Tiled I assign a rotAngle (the current spot in the rotation) and a radius (the number of tiles I'd like it to cover). Unfortunately, I have no idea what I'm doing. I can't seem to get the sprite to move faster along the circle (increasing the speed parameter just seems to make the circle larger and body.angularRotation, body.angularAcceleration, and body.speed don't seem to help either), and I'm not at all certain how to ensure the radius in tiles (a tile for me is 32x32). Also, when this sprite gets to the end of a full rotation, it is not where it started, it's somewhere off to the top-left. I can't figure out how to determine why it's doing that. Overall, I'm just sorta confused about this whole ordeal. Any ideas?
13. Sprites are blur on rotation, falling and jumping

I've making my first game so far is great but I have a display problem. when I rotate the sprite it become's blurry, same happens on jumping and falling the sprite turns blurry. Can anyone help me fix it. I'm using Chrome with WebGl and WebAudio. is there anyway I can make the sprite to not become blurry...Thanks By the way Wonderful framework I started the styding and making the game last night and I'm closer to finished thank you. And from the google searching I see that the administrators (are those the creators?) are responding quickly... Just great keep up
14. Rotate a Camera

Using an ArcRotateCamera you can set the rotation on creation of the camera, is there a way to do something like, camera.rotation.x and camera.rotation.y to change the rotation of a camera already in the world? I'm assuming that it would be better to not just make a gazillion cameras every time that I want to manually change the rotation though as far as I can see the only way to set a camera is on creation! When I try my method above it just says "Cannot set property 'x' of undefined".
15. sprite.rotation for shooting a bullet?

Hello, I was studying from code in 'Tanks' example game that came with Phaser package in github. I was looking for line of code that set speed of enemy's bullet and how it shoot to player. I found this very line: bullet.rotation = this.game.physics.moveToObject(bullet, this.player, 500);It comes out that this line makes the bullet shoot to player. In my sense, bullet.rotation should only change the angle of the bullet, but didn't apply any velocity for it to move. Could you explain how does this work? p.s. Sorry for dumb question here. I am just trying to understand the code.
16. Group rotation

Hi, I started to create a simple game - tetris. Unfortunately I have 2 problems: - how to move group rotation point from top left corner to the center? - is there a possibility to check collision when moving group by change x property (I override tween, but it still moves down)?
17. How does angle work?

Hey folks! I'm trying to make a game of Asteroids, and I want to steer my ship! So I added the following code to change the angle: if(game.input.keyboard.isDown(Phaser.Keyboard.D)) player.angle++;It works at first, but then it gets stuck and the angle won't change. Generally this happens after 360* or so. I'm guessing that this has something to do with the number getting too large (which mathematically shouldn't make a difference, right?). I created a workaround: var rotation = 0;function update() { if(game.input.keyboard.isDown(Phaser.Keyboard.D)) player.angle = rotation++ % 360;}But creating my own rotation variable seems to defeat the purpose of having an angle variable in the first place. Am I doing something wrong? Is there a better way to make use of angle? I've been looking through the source, but I haven't had much luck yet (JavaScript is not my first language). Thanks & Regards.