Garalda Posted March 22, 2016 Share Posted March 22, 2016 Hi, I would like to create game, where is possible move camera only by predefined steps from square to another square. Here is sample what I want: playground steps example When i try to move with default babylon arrow keys, collision works fine. But when I use my step keys (W A S D), collisions are ignored. And another variant which I would like to use are predefined steps with move animation: playground steps with animation example Is there any way how to detect collisions with animation? Thanks Quote Link to comment Share on other sites More sharing options...
Garalda Posted March 23, 2016 Author Share Posted March 23, 2016 Well it looks my question is stupid or not understandable, sorry about my english. Probably problem is, that I use my own keys for movement so babylon doesnt fire default events with collisions? Can I hook this events myself? About animation movement I was thinking that instead of animation I can set velocity and call MoveWithCollisions, but it looks it is not working with camera, only with objects. Or is there solution how to use it with camera? Thanks for your help Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 23, 2016 Share Posted March 23, 2016 Hi! If you want to add WASD instead (or together with) the arrows, simply add them to the keys arrays. for example check how I added the 'w' key (code 87) to the keyUp array (line 17) - http://www.babylonjs-playground.com/#19SAQS Now 'w' works as forward. Is that what you wanted? Quote Link to comment Share on other sites More sharing options...
Garalda Posted March 23, 2016 Author Share Posted March 23, 2016 10 minutes ago, RaananW said: Hi! If you want to add WASD instead (or together with) the arrows, simply add them to the keys arrays. for example check how I added the 'w' key (code 87) to the keyUp array (line 17) - http://www.babylonjs-playground.com/#19SAQS Now 'w' works as forward. Is that what you wanted? Hi, thanks for your reply. I used WASD keys because I dont want use continuous movement, but move by predefined steps, you can imagine it as moving on chessboard. I want to jump from centre of one square to centre of another squre directly. I suppose for arrow keys there is some low value, for steps for example 0.01, but I want to do step for example by 5. I think, that in this case collisions are not fired, because I jump over collision detection area. Quote Link to comment Share on other sites More sharing options...
RaananW Posted March 23, 2016 Share Posted March 23, 2016 How about changing the camera's speed? http://www.babylonjs-playground.com/#19SAQS#2 Quote Link to comment Share on other sites More sharing options...
Garalda Posted March 23, 2016 Author Share Posted March 23, 2016 1 hour ago, RaananW said: How about changing the camera's speed? http://www.babylonjs-playground.com/#19SAQS#2 Hi, thanks, this looks like possible solution. But can you please check why in this sample http://www.babylonjs-playground.com/#19SAQS#4 works collisions on move left (green) or right (red) planes, but not when I go forward (blue plane)? Is there any way to use html buttons for movement instead of arrow keys? Can I fire arrow key press event from javascript? Thanks 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.