Alenvei

Members
  • Content count

    42
  • Joined

  • Last visited

About Alenvei

  • Rank
    Advanced Member
  • Birthday August 27

Contact Methods

  • Twitter
    dayest

Profile Information

  • Gender
    Male

Recent Profile Visitors

446 profile views
  1. Alenvei

    GUI issue with raycast

    Thank you for lesson @Wingnut it works perfectly .
  2. Alenvei

    GUI issue with raycast

    Hello again @Wingnut I found one issue but not with label and raycast. I have issue with animation of doors ... You can see exampel in my last post. When I turn on my "game" everything works fine but after five minutes when I open door the FPS go like crazy and evrey minute it's worse only with door animation. I think the raycast making this trabels but I'm not sure.
  3. Alenvei

    GUI issue with raycast

    Hi @Wingnut ..... this is awesome it works perfectly and I learned new things ...thank you very much Wingnut for me you are pro coder . Guys I made for you playground, which is similar with my game . You can find there two rooms with doors. Go close to the door when label ( with the letter E) shows up then press the E-key on keyboard and see the magic W,A,S,D keys to control the RedBox. Have fun: https://playground.babylonjs.com/#VZRN2V#7 I changed this lines : -Lines 26 -97 : only walls -Lines 163 -194 and 219 : implementation animation for doors ; -Lines 230 : executing animation for doors Have nice day
  4. Alenvei

    GUI issue with raycast

    Hello @Wingnut Thank you for your answer... I very appreciate. I was afraid that I will must use more then one label 😕..... ...because in future I would like to make five more doors and more diffrent "labels" (G, F, Q - keys on keyboard) in first level. I am not sure if It will be good for game performance create custom labels for each door What is your opinion guys ?
  5. Alenvei

    GUI issue with raycast

    sorry I forgot for exampel.... here you can try : https://playground.babylonjs.com/#VZRN2V You can see in exampel GUI works with blue Bigbox, but with green Bigbox doesn't works . Why it is so ?
  6. Alenvei

    GUI issue with raycast

    Hello all Sorry for my bad english in advance . I have a littel issue with GUI and I want to understand why it works like taht . What is the issue ? I made this function : function vecToLocal (vector, mesh){ var m = mesh.getWorldMatrix(); var v = BABYLON.Vector3.TransformCoordinates(vector, m); return v; } class Raycast { constructor() { } doorOpener(letHit, myGUI, scene){ this.scene = scene; var origin = player.position; var forward = new BABYLON.Vector3( 0, 0, 1,); forward = vecToLocal(forward, player); var direction = forward.subtract(origin); direction = BABYLON.Vector3.Normalize(direction); var length = 1.5; var ray = new BABYLON.Ray(origin, direction, length); var hit = this.scene.pickWithRay(ray); if (hit.pickedMesh == letHit){ if (control.keys.ePress == 1){ scene.beginAnimation(letHit, 0, 40, false); } return myGUI.isVisible = 1 }else { return myGUI.label.isVisible = 0; } } } This function is responsible to opening doors. When player reach a door then GUI shows up which key(E) on keyboard must be pressed for open the door but the GUI only works whith one door . Here is how I call Raycast function : const view = require('./ray.js'); const panelG= require('./gui.js'); class Leves { constructor(scene,camera,followCam,canvas) { this.scene = scene; GuiP = new panelG.GuiP (scene); doo = new view.Ray (); BABYLON.SceneLoader.ImportMesh("", "textury/mapy/", "lvl01.babylon", this.scene,function (newMeshes) { var level_001 = newMeshes[0]; level_001.checkCollisions = true; var door = newMeshes[1]; door.checkCollisions = true; var door2 = newMeshes[2] door2.checkCollisions = true; var openDoor = new BABYLON.Animation("t", "position.z", 25, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); var keys = []; keys.push({ frame: 0, value: 0.45 }); keys.push({ frame:5, value: -1.5 }); keys.push({ frame: 10, value: -3 }); keys.push({ frame: 30, value: -3 }); keys.push({ frame: 35, value: -1.5 }); keys.push({ frame: 40, value: 0.45 }); openDoor.setKeys(keys); door.animations.push(openDoor); door2.animations.push(openDoor); scene.registerBeforeRender(function () { doo.doorOpener (door, GuiP.panel, scene ); /*only animation works*/ doo.doorOpener( door2, GuiP.panel, scene); /* GUI and animation works very good */ }) }) } } I am newbie in babylonjs and javascript too and I want to understand every aspect of babylon js and javascript.
  7. Alenvei

    Raycast - bug or not ?

    Thank you again @Dad72 Yes your second exampel worked for me
  8. Alenvei

    Raycast - bug or not ?

    I understend @Dad72.. so raycast can´t pick only specific obj ? for exampel : only doors in room with lot of other obj in it
  9. Alenvei

    Raycast - bug or not ?

    @Dad72 I have one question for you I am making littel "Space-RPG" and question is : Can I make 2 imported obj in ma game like for exampel player and door intersect with raycast (raycast is a part of the player ) if i using this mathod : if (rayCast.intersectsMesh(door, true)) { console.log("open"); } else { console.log("closed"); } I have littel problem whit it 😕 it doesn't register intersection
  10. Alenvei

    Raycast - bug or not ?

    Thank you very much @Dad72
  11. Alenvei

    Raycast - bug or not ?

    Hello I found one bug I think. In this exampel https://www.babylonjs-playground.com/#KNE0O#4 I found this example o https://doc.babylonjs.com/babylon101/raycasts ray.show(scene, new BABYLON.Color3(1, 1, 0.1)); When I tried this code, which was prepared in exampel then babylon.js stop worked. Sorry for my poor english.
  12. Alenvei

    Camera smooth reset position;

    ehm i think i figured out when i posted my last comment I tried this : if (camera.alpha < 4.71238898038469){ camera.alpha += 0.04; } if(camera.alpha > 4.71238898038469){ camera.alpha -= 0.04; } and it worked i think this forum has some wierd aura or somthing always when I post some issue a few minutes leter I figured out out what I need Thanks again for you long post @Wingnut
  13. Alenvei

    Camera smooth reset position;

    Hello @Wingnut Your exampel it's very cool I realy like it ...thank you .But this is not what i am looking for. The game what I am working is RPG game. And my I idea is make camera, which player can see of terrain around him and if he don't want the "free view funcion " player press for exampel "C" key for funcion camera locked behind player and here is thing, he can still moving around the camera but when he press the "WASD" keys then camera smoothly rotate behind the player. If I use camera.parent = player; instead camera.target = player; then value of the camera.alpha is not changed, this is great because we know starting point of our camera, which in my case is value = 4.71238898038469; but when plyer start rotate whith camera becous he want to see terrain of course value of the camera.alpha starts to increase, so here is question: How can I make the camera calculate rotatation exatly behind the player ? During writing this coment I set the rotation of the camera like this : if (camera.beta < 0.1){ camera.beta = 0.1 }else if(camera.beta > (Math.PI / 2 *0.95) ){ camera.beta = (Math.PI / 2 *0.95) } if(camera.alpha < 4.71238898038469 - Math.PI){ camera.alpha = 4.71238898038469 - Math.PI }else if (camera.alpha > 4.71238898038469 + Math.PI){ camera.alpha = 4.71238898038469 + Math.PI; } So if player rotate: - Math.PI or +Math.PI; with this I make for the camera some borders so we can now easily calculate how far the camera rotate. Ok now if the camera rotate for exmapel to the camera.alpha = 2.71; then we need value 2 because 2.71+2 = 4.71:(this is value of camera.alpha behind the player ) simpel math right ? Here is code what I mean almost with my silly math exampel if(camera.alpha!=4.71238898038469){ camera.alpha +=0.01; } but it never will by exactly 4.71238898038469; I know you are asking .... "where is your math exampel what you write higher in the coment ?" ... the truth is I don't know how implement this exampel I only know that I can make it with for() loop; but I don't have so much experience. What you thing it is posible make something like that ? Again sorry for my bad english If anything is unclear, let me know .
  14. Hello evryone Sorry in advance for my bad english; I wanna ask somthing about .ArcRotateCamera (); I want to make camera with locked position behind the player when the player moving but if player stand on the place he can moving around with the camera and when he again start moving the camera smoothly rotating to the locked position. I wondered if I will make somehow the camera will checking position.z of the player then camera will be calculate position behind the player. Here is my player how move in game for better understending: http://www.babylonjs-playground.com/#TGA1QA By the way I only want some tips or show me a way how I can make this work out I want to fully understand how javascript and babylon.js works. Thank you.
  15. Alenvei

    Class() - unable to import meshes

    ok I solved that in get mesh(){ return _this.collider } I changed _this.collider to this.collider and now is it working perfectly .