Problem: Getting a camera to follow a ball.
I am looking at getting a game to have a camera follow a ball like this:
So that is, if a user moves on the X-Axis the camera will yaw around and now when a play presses forward it goes in the forward direction of the camera. I am really stuggling to get the camera to yaw around the y axis to achieve this.
Methods I have tried:
- Placing the camera as a child of the ball entity, with no scripts. Like so:
https://launch.playcanvas.com/1069257
Problem: The camera rotates with the ball, causing the camera to be totally crazy.
- Having a camera as a root entity, and adding a follow script found in one of the tutorials:
You can find that with same PC link as above, but with 1069260 as the id.
Problem: The camera does not rotate around the y-axis so the camera is always facing the forward direction of the ball.
- Editing the ‘3rd person controller’ tutorial to suit my needs
You can find that with same PC link as above, but with 1069262 as the id.
This one has yielded the closest thing to success, but I am struggling to get the camera to feel less jolty.
I don’t really understand how to lerp this line:
originEntity.setEulerAngles(targetAng);
Found in ‘CameraMovement.js’ under postUpdate().
Questions
Can anyone point me in the right direction on how to solve this? I know my understanding is a little limited and I proberly need to learn all this a little bit more, but was wondering if anyone has solved a similar problem?
If not, can anyone point me to some good learning resources for this exact problem?
Many thanks,
James
Sorry, as a new user I can only post two links.