Jump to content

Search the Community

Showing results for tags 'right'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 3 results

  1. In unity they have transform.forward, right and up. The docs for unity say the forward is : 'The blue axis of the transform in world space.' using UnityEngine; using System.Collections; public class ExampleClass : MonoBehaviour { public float thrust; public Rigidbody rb; void Start() { rb = GetComponent<Rigidbody>(); } void Update() { rb.AddForce(transform.forward * thrust); } } How would I do this in Babylon.... Yo @Deltakosh or ANYBODY How do we get the forward vector in Babylon... Would this work: /** The blue axis of the transform in world space. */ public static GetForwardVector(mesh:AbstractMesh, force?:boolean):BABYLON.Vector3 { var matrix:BABYLON.Matrix = mesh.computeWorldMatrix(force); return BABYLON.Vector3.TransformCoordinates(BABYLON.Vector3.Forward(), matrix); } /** The red axis of the transform in world space. */ public static GetRightVector(mesh:AbstractMesh, force?:boolean):BABYLON.Vector3 { var matrix:BABYLON.Matrix = mesh.computeWorldMatrix(force); return BABYLON.Vector3.TransformCoordinates(BABYLON.Vector3.Right(), matrix); } /** The green axis of the transform in world space. */ public static GetUpVector(mesh:AbstractMesh, force?:boolean):BABYLON.Vector3 { var matrix:BABYLON.Matrix = mesh.computeWorldMatrix(force); return BABYLON.Vector3.TransformCoordinates(BABYLON.Vector3.Up(), matrix); } Also I saw some c++ code for getting forward vector using the quaternion, could I use this in babylon or SHOULD I even try use in Babylon ... Is there something already in Babylon for this: Vector3 Quaternion::GetForwardVector() const { return Vector3( 2 * (x * z + w * y), 2 * (y * x - w * x), 1 - 2 * (x * x + y * y)); } Vector3 Quaternion::GetUpVector() const { return Vector3( 2 * (x * y - w * z), 1 - 2 * (x * x + z * z), 2 * (y * z + w * x)); } Vector3 Quaternion::GetRightVector() const { return Vector3( 1 - 2 * (y * y + z * z), 2 * (x * y + w * z), 2 * (x * z - w * y)); } Or am I way off
  2. Hey guys I'm making a platformer and I've managed to get my character running and jumping at the same time... to one side only - the right! I have NO ideia why running and jumping to the left is proving impossible but I'm hoping you can help me out. runKey = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); // The running key, in the create method // Fast forward to my update method (...) // Horizontal movement player.body.velocity.x = 0; // Resets our character's horizontal movement. if (cursors.left.isDown) // If the 'left' key on our keyboard is pressed ... { player.scale.x = -1; // ... we horizontally flip our character to face the left ... player.body.velocity.x = -200; // ... we move him to the left ... player.animations.play('walk'); // ... play the 'walk' animation ... player_walk.play('', 0, 1, false, false); // ... and finally play the 'player_walk' sound effect. if (runKey.isDown) // If the 'run' key on our keyboard is being pressed while we are walking to the left... { player.body.velocity.x = -350; // ... we allow our character run to the left. } } else if (cursors.right.isDown) // If the 'right' key on our keyboard is pressed ... { player.scale.x = 1; // ... we horizontally flip our character to face the right ... player.body.velocity.x = 200; // ... we move our character to the right ... player.animations.play('walk'); // ... play the 'walk' animation ... player_walk.play('', 0, 1, false, false); // ... and finally play the 'player_walk' sound effect. if (runKey.isDown) // If the 'run' key on our keyboard is being pressed while we are walking to the right... { player.body.velocity.x = 350; // ... we allow our character run to the right. } } else // If no key on our keyboard is pressed ... { player.animations.play('idle'); // ... play the 'idle' animation ... } // Vertical movement if (cursors.up.isDown && (player.body.blocked.down || player.body.touching.down)) // If the 'up' key on our keyboard is pressed and our character is touching a surface ... { if (runKey.isDown && player.body.velocity.x < 0) { player.body.velocity.x = -350; player.body.velocity.y = -700; player_jump.play('', 0, 1, false, false); jumpCounter = 1; } else if (runKey.isDown && player.body.velocity.x > 0) { player.body.velocity.x = 350; player.body.velocity.y = -700; player_jump.play('', 0, 1, false, false); jumpCounter = 1; } player.body.velocity.y = -700; player_jump.play('', 0, 1, false, false); jumpCounter = 1; } else if (player.body.velocity.y < 0) { if (runKey.isDown && player.body.velocity.x < 0) { player.body.velocity.x = -350; player.animations.play('jump'); player_walk.pause(); } else if (runKey.isDown && player.body.velocity.x > 0) { player.body.velocity.x = 350; player.animations.play('jump'); player_walk.pause(); } player.animations.play('jump'); player_walk.pause(); } else if (player.body.velocity.y >= 0 && !(player.body.blocked.down || player.body.touching.down)) { if (runKey.isDown && player.body.velocity.x < 0) { player.body.velocity.x = -350; player.animations.play('fall'); player_walk.pause(); } else if (runKey.isDown && player.body.velocity.x > 0) { player.body.velocity.x = 350; player.animations.play('fall'); player_walk.pause(); } player.animations.play('fall'); player_walk.pause(); } else { jumpCounter = 0; } I really don't understand what's wrong Thanks in advance!
  3. Hello everyone, I'm fairly new to Phaser, and I'm just starting to figure things out. I made a simple prototype that uses "game.input.keyboard.createCursorKeys()" to listen and process the keyboard's cursor keys. Basically I have a sprite that moves up, down, left and right depending on input. Now I'm trying to achieve the same using touch events: when I swipe left, the sprite moves left; when I swipe up, the sprite moves up, etc.... but with no success. I've managed to detect swipe using a solution that user @imshag posted in this topic: http://www.html5gamedevs.com/topic/3862-swipe-to-jump/?hl=%2Bswipe+%2Bphaser#entry24473 It detects swipe, but doesn´t give me info on the direction of it. I could really use your help... How can I detect the direction of a swipe, and limit it to "up", "down", "left" and "right? Thanks in advance!
×
×
  • Create New...