DigitalHilsone Posted July 31, 2015 Share Posted July 31, 2015 Guys, please help to deal with the movement of the model (car). I wrote some code, but it is not working. Point me in the right direction.var Control = (function () { function Control() { this.c = 0; } Control.prototype.keyUp = function (key) { switch (key) { case 39: Control.moveLeft = false; break; case 38: Control.moveForward = false; break; case 37: Control.moveRight = false; break; case 40: Control.moveBackward = false; break; } }; Control.prototype.keyDown = function (key) { switch (key) { case 39: Control.moveLeft = true; break; case 38: Control.moveForward = true; break; case 37: Control.moveRight = true; break; case 40: Control.moveBackward = true; break; case 68: if (this.c % 2 == 0) { Control.driftMode = true; } else { Control.driftMode = false; } this.c++; break; } }; Control.moveForward = false; Control.moveBackward = false; Control.moveLeft = false; Control.moveRight = false; Control.driftMode = false; return Control;})(); Quote Link to comment Share on other sites More sharing options...
iiceman Posted July 31, 2015 Share Posted July 31, 2015 Uhhmmm.. maybe a playground would be a good idea Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 1, 2015 Share Posted August 1, 2015 I can't agree more Quote Link to comment Share on other sites More sharing options...
DigitalHilsone Posted August 1, 2015 Author Share Posted August 1, 2015 I'll tell you the essence - have a car, and I did not get her to learn to ride the stage for arrow keys. That is, the forward arrow - gas back - brake well, and left \ right the associative Could you help with the implementation of this task? Quote Link to comment Share on other sites More sharing options...
iiceman Posted August 2, 2015 Share Posted August 2, 2015 Still, you should show us in a playground what you have so far. There is a demon of a basic car game on the BJS homepage: http://www.babylonjs.com/ (scroll all the way down and you should see it) I moved it to a playground: http://www.babylonjs-playground.com/#WLZ9C Quote Link to comment Share on other sites More sharing options...
gryff Posted August 2, 2015 Share Posted August 2, 2015 Point me in the right direction. DH : maybe have a look at Temechon's "How to use Actions and ActionManager" tutorial. The code only moves the "Ship" right and left - but can be easily modified. cheers, gryff Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.