Orange Room moving with touch

Hi there !

I am working in the Orange Room scene modifying some stuff and since I’ve made my character “colliding” everything works perfectly on my browser but when I’m opening it in my browser’s phone I can only move back and forth but I cannot turn my head (The second touch pad doesn’t work).
Can someone tell me what is broken?

Link to my project :

Thanks in advance,


I have found that touch.js is using “this.entity.script.flyCamera.rotate(-this.tmp.y * .7, -this.tmp.x);” to rotate but my first-person-movement.js hasn’t such thing. So I have to convert the mouse movements for the touch or change my first person movement to use the same thing as the fly camera. I don’t know yet how I will do this but I’m gonna try !

Looks like you’ve renamed a script from “First_person_movement” to “first_person_movement” and the code in touch.js is expecting the capital letter.

(If you haven’t yet found it: remote debugging on android is great:

1 Like

I’ve tried to change the capital letter but it still refuses to work :frowning:
I put back the initial version of the code which is asking in touch.js for “flyCamera.rotate” (line 131). I can’t see what to do in order to making the right joystick work with first-person-movement.js as it’s using the movement of the mouse just like fly-camera.js (that was initially in Orange Room) but in a different way.

So, I’ve keep trying using elements from fly-camera.js and puting them into my first-person-movement.js so the touch script could use it but I don’t know how to do it.

I’m asking myself what in the maths of first-person-movement.js could be used to make the right joystick moving the orientation of camera?

Link to my project :

@Denis_Henon try this version on your phone and let me know if it works

1 Like

Wow thanks vrejaandrei !
yes it works but I think there is a problem with the rotation pivot as the camera with the right joystick makes it rotate but also moving in the space (if I keep the right joystick up I’m going down like a plane and I’m making a looping.
Is there any way to just make it rotate?

Also when you launch the scene on a computer the controls are only made with flycamera and not first-person-movement.js

Thanks again !

1 Like

@Denis_Henon take a look again, it should be all good now.

Thanks for your answer, the rotation on right joystick is acting weird if you rotate on the right and then try to go ahead with the left joystick it didn’t go in the direction of where you are looking at (as if the camera and the player where moving independantly). Plus if I try to open on my computer browser it’s using the flycamera not the first-person-movement.js script we shouldn’t be using the flycamera script.

Thanks again to you !

Well, you should really remake the scripts then, as in, take only what’s necessary and move every part of code in the “right” place.

I have made some progress, I’ve separated the right and left joystick just to be more clear in my head.
And assign leftjoystick + first person movement to my player and my right joystick + fly camera script for rotation to my camera. Now in my scene the right joystick works my camera is rotating the way I want and the left joystick is also making translate the player but only on basics axis (not depending on the camera axis only his local axis I guess)
So I tried to get the camera vector but nothing worked.

To sum I would like that my player goes in the direction he is facing when I move the left joystick.

I think it’s in these lines of code :

if ( == this.joyLeft) {
                    this.tmp.copy(this.vec).scale(1 / (this.size / 2 - 24)).scale(2 * dt);
                    this.entity.translateLocal(this.tmp.x, 0, this.tmp.y);

I think I’m close of what I want to do but I don’t get this problem of axis.

Does anyone can help me?

Link to my project :

I don’t understand, that’s what my edits are doing. The right stick is rotating the character and the left one is moving it relative to the rotation. I moved the touch script from the player to camera(to fix the rotation offset). You really don’t have to move touch code to first person movement as the touch is just a “wrapper” that sends info to first person movement and fly camera. The project I posted works just fine in both mobile and desktop browsers.

Why exactly do you want to move touch code to first person movement?

Because I don’t want to “fly” In the appartment I want the “body” to move with the left touch stick on mobile and with the keyboard on computer(so this is translation) and I want the “head” to move with the right touch stick on mobile and with the mouse while clicking on computer(rotation). I’m close to this In my last version except the body isn’t going In the direction the player is facing. Am I doing this all wrong??

What exactly is happening for your using my project(I deleted the graphics from it today as it was exceeding my spake)? For me, on desktop, I rotate with my mouse and you move relative to rotation, so you can fly up and such. On mobile, left stick is movement(same as desktop keys), right stick is rotation. It all works fine for me, I can’t see the problem.

When using the link you gave above on mobile I’m flying like a drone in the scene. I can go on the ceiling if I want to. Added to that if you are playing a few seconds turning around, the left stick is not following the direction of the camera to move if the right stick is not facing the axe I had while spawing. This last thing is the same thing that I have in my last version.

I don’t think you mentioned that you want it to move like a character. I assumed that because of the foot steps but was not sure. You have to lock the Y axis and that should help. Now, there are many ways to do that. You could either change the math on the movement or add a line for code in the update that will stick the character back to floor. I’ll try do that for you tomorrow.

1 Like

Thanks a lot for the help mate !

Yes ! I locked the Y axis and it works like a charm ! Sorry for not getting this sooner…
I have one question now I juste have the camera and how could I have collision on walls with it?
If I add collision and rigid body components I can’t move anymore.

Thanks again for the help !!

Be sure that your character is not inside the floor(tho, I think it would automatically get snapped above/below it). Also, you could consider placing the rigidbody on the camera, this would also make sure it doesn’t clip through objects, I guess… I am still new to this stuff.

My character is not inside the floor and I placed rigidbody on camera and collision but it didn’t take into account any collision I don’t get why :frowning: