Hi,
I want to use a RollerBall prefab, but I want to change its control
I want to make the ball move only forward and backward, so I changed the BallUserControl script to make it work. “A” and “D” used to rotate camera around the ball.
I have implemented a CameraFollow by this code:
You need to variables, a distance, and an angle, the distance will be the distamce between the camera and the player. If you press a, add to the angle, if you press d, remove from it, then set the offset x to distance * mathf.cos(angle), and the z to distance * mathf.sin(angle), then set the position to offset + playerpos
Don’t do offset.x = offset.x *… Use a distance instead, a distance from the camera and the player, so offset.x = dist *…
Because you’re working in c, you can’t set these values separately, do offset = new vector3(offset.x here, offset.y, offset.z here).
Remove the transform.position sets from lateupdate, and move followplayer(); line to the end of lateupdate
Wait, wait wait
I noticed a one more little problem with this:
I start the scene and when a first press “A” or “D” the camera is going to left side of the ball, later its work properly.
What’s the reason of this?
The code again: