I was making a 2.5D top down style shooter game (graphics are in 3D), and wanted to use the FollowCamera (Which is amazing!). But the problem I am encountering is that the camera rotates as the mesh rotates, which is not what I want. I went out trying UniversalCamera and ArcRotateCamera but the movement of it when following the mesh is jittery. I’m not sure whether 1) I am implementing the follow movement of UC and ARC in the wrong way, 2) is there an option to disable the FollowCamera from turning due to the mesh, 3) is there an alternate camera for this use? . Could someone help me here? I’m new to BJS, so I don’t have much experience.
Thanks a lot to reading through! Thanks in advance!
you could try mesh.position.add(new BABYLON.Vector3(0, 10, 0));
This acts like parenting but without the rotation. You’ll have to call it every frame, though, so
That shouldn’t have any effects on it. Or does it?
I don’t think it should because I’ve been using mesh.position.add with a mesh that has physics and it doesn’t change anything. It’s like parenting, except the child mesh doesn’t inherit the parent’s rotation.
@Givo Oh no I’m sorry for the miss understanding, I thought you would try to show an example in a pg! Anyways, I tried it out, not able to figure out what exactly you meant by .add…
Wow thanks a lot @Givo ! I misunderstood the way I should use mesh.position.add (thought that I should trigger that whenever I press a movement key ). I had the controls ready, I just didn’t understand what you meant. I went through the docs, it said .add is used for adding two vectors. I thought you meant me to use it to move the mesh!
Hmm so now I have found the answer, just for curiosity, isn’t the .add method gonna do the same thing as equating (is it the right term I’m using?) the player/sphere position with the camera position?, cause when I do it manually, I see the jitter…
Oh, it’s fine. I really didn’t explain it all that well. By the eqating, do you mean that it would make the player’s position the same as the camera’s? And when you do camera.position = new BABYLON.Vector3(player.position.x, player.position.y + 10, player.position.z); the camera jitters?
You tried parenting the camera to the player, right? Did it jitter then?
Yes @Givo , it does jitter, I mean, I did this exactly: camera.position.x = player.position.x; camera.position.y = player.position.y + 10 camera.position.z = player.position.z + 2 Which makes really no difference than defining a new vector, Or does it?
Uhm no I didn’t try parenting the camera, did you mean camera.parent = player;?
EDIT: Let me try out everything you mentioned, please give me some time!
EDIT (2): Yes @Givo , it does jitter by the above method you mentioned, plus parenting it makes the player’s rotation affect the camera .
Anyways, the .add method is working perfectly! Just had to ask whether we are allowed to talk in such a way on a post (with around 15 replies), or should we talk in a private message…just had a concern about that.