Currently I working on a project which player able to look at the mouse position (lookat.js) and clamp it along Y axis. It work well but the problem come when I add movement.js. The code of movement.js is from the realtime player tutorial movement.js and it use this.entity.forward or this.entity.right to move the player.
When I try to launch the game the movement.js and the lookat.js do not work as I expected. It either looking forward and move forward or the player stay in that position and look at the mouse position. Is that other ways to make the movement.js and lookat.js able to work simultaneously ?
Hi @Elliot! I made an attempt, but unfortunately my knowledge is insufficient to find out why the result is not as expected. Other than that, I think the Third Person Controller does what you want, so maybe you could check that out.
@Albertos Thanks for reply. I take a look at the link that you share, actually it quite good. But I wanna do something like a tank game and isometric camera angle.
Third Person Controller the direction define by the camera but what I trying to achieve is direction define by mouse position. The reason that I wanna done it in isometric due to it is easier to observe the surrounding and environment.
Alright. In my own game I use kind of the same way of movement, but the biggest difference is that I don’t use physics. So I can use translateLocal to move my player forward in the direction of the mouse. I hope someone else can see why your player is not moving in the right direction.
Hello, the main issue is that when the key.ispressed the mouse pointer don’t move so the lookat function become useless, i don’t know if there is a way to solve that since i never had the need to dig into it, from what i noticed around it’s a pretty common issue in all games that use the keys to move and the mouse as in Winter Blast game. You should focus on a way to bypass this limitation. Good luck.
So far what I get is to separate the head and body part. Add movement.js to the lower part (make the lower part transparent to make it invisible) and add lookat.js to the upper part. I get the idea from this project but unfortunately it not updated to the latest engine otherwise it will be a good start for those who wanna do an isometric 3D game. Hope the owner can updated it in the future.
Hi @Elliot! I asked @yaustar to look into this problem and he made a sample project. I think it works wonderful! You can fork this project and tweak it where you need.
As far as I understand the solution to your problem is to make your model as a child of your rigidbody entity. Because you don’t rotate the rigidbody itself when you use lookAt, your rigidbody entity falls back to the original rotation when you apply some force.