droggam Posted October 2, 2018 Share Posted October 2, 2018 Hello coders, I tried scene.actionmanager( etx and if(evt.sourceEvent.key=='f') { Let sphere666= etx sphere666.position.y= evt.pointerY } so basically what I want is press f and create sphere at where mouse is at the code is THE parts i remember rn. problem is its not Creating a sphere but pointerX is correct values etx anyone can help? Quote Link to comment Share on other sites More sharing options...
JohnK Posted October 2, 2018 Share Posted October 2, 2018 Hi @droggam and welcome to the forum. Could you make a playground with what you have so far, that really helps us to help to. Quote Link to comment Share on other sites More sharing options...
droggam Posted October 2, 2018 Author Share Posted October 2, 2018 @JohnK Well thanks i Guess im on mobile. problem but i Will try later again Quote Link to comment Share on other sites More sharing options...
trevordev Posted October 2, 2018 Share Posted October 2, 2018 @droggam try this http://playground.babylonjs.com/#571YN6 Quote Link to comment Share on other sites More sharing options...
droggam Posted October 2, 2018 Author Share Posted October 2, 2018 PG is not working for me att all only get directed to default template @trevordev Quote Link to comment Share on other sites More sharing options...
trevordev Posted October 2, 2018 Share Posted October 2, 2018 @droggam It works for me, maybe try again, it looks like the default playground but if you click on the platform the sphere should move Quote Link to comment Share on other sites More sharing options...
droggam Posted October 3, 2018 Author Share Posted October 3, 2018 @trevordev Hi i Will Keep trying. I tried gui lib No luck Babylonjs GUI i mean what wrong with it? Trevor I really tried solve My puzzle So far this is what i found out I see that pointerX is 666 value and it need divide It 100 Times to even see THE new created ball in THE screen when So how do i translate pointerX to real value in babylonjs vector3? Quote Link to comment Share on other sites More sharing options...
JohnK Posted October 3, 2018 Share Posted October 3, 2018 Hi again @droggam I know it is frustrating for you but we do need a working or nearly working playground to build from. The playground from trevordev http://playground.babylonjs.com/#571YN6 does work even if it is not exactly what you want. In this playground click anywhere on the grey square and the sphere will jump to that position. Instead of making the sphere jump could you make a sphere appear at the place where you click. When you have done this then explain a small change that you want to make to get it closer to your final goal. trevordev 1 Quote Link to comment Share on other sites More sharing options...
droggam Posted October 3, 2018 Author Share Posted October 3, 2018 http://www.html5gamedevs.com/topic/33751-problems-with-playground-url/ i have the same problem rn cant use pg but thanks for help. Later.. Quote Link to comment Share on other sites More sharing options...
trevordev Posted October 3, 2018 Share Posted October 3, 2018 @droggam You could try to use offsetX instead of pointerX, offsetX will be the pixel offset of the canvas you clicked on. You can then use scene.getEngine().getRenderingCanvas().width to get the width of the canvas. Subtract scene.getEngine().getRenderingCanvas().width/2 from the offset X and you have the distance in pixels from the center of the canvas. Multiply this by a ratio to convert pixel distance to meters (eg. 1/100) and set the x position to that. Maybe that is more what you are looking for? Quote Link to comment Share on other sites More sharing options...
JohnK Posted October 3, 2018 Share Posted October 3, 2018 54 minutes ago, droggam said: i have the same problem rn cant use pg Can you try a different browser? Quote Link to comment Share on other sites More sharing options...
droggam Posted October 3, 2018 Author Share Posted October 3, 2018 Ye i Will try i started out with phaser3 And happy i changed to babylonjs. Feel like more fun n documentation I just feel gamedev in general is buggy and errorprone What is offset exactly i Will research for sure but IF pointerX is not correct how to builds working game. And another question what is a Good approach of i want say a grid and put items in THE small boxes like i Said tried install babylonjs GUI but it couldnt find THE packade in npm terminal @trevordev Quote Link to comment Share on other sites More sharing options...
droggam Posted October 4, 2018 Author Share Posted October 4, 2018 @JohnK IF i use proxy on phone i get directed to correct PG id but PG is not used for tablets No luck on laptop but I Read some of THE code i Will try use it 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.