- Home /
[Closed] SmoothFollow trouble
I'm just starting out with Unity3d and I thought I would make a really basic 2d platformer just to get used to Unity. All I've done is made a platform and added in a first person controller. I was loosely following an online tutorial and he removed pretty much all the scripts on the FirstPersonController and added the PlatformController. I tried this but Unity wouldn't let me get rid of the CharacterMotor. Anyways, after setting the PlatformController to only move in the Z direction instead of Z and X I decided I wanted the main camera to follow my character.
I found a SmoothFollow script and figured that would work. I attached the smooth follow script to my main camera (deleted the one attached to the FPController so main camera is not a part of FPC) and set the target transform to my FPC.
When I tried to play the game, the camera spawned in the position and rotation I wanted to (from the side looking purely in the x direction) but it immediately swung around to behind the camera. This also messes up my FPC since I still move side to side relative to the camera which means I can't move down the platform anymore, just of the short side which I should not be able to move. In addition to the rotation issue, the camera doesn't actual move, at all. I can run and jump off the side of the platform and the camera stays put at it's initial resting place.
I checked the script and it's always moving towards the targets eulerAngles. I looked up the eulerAngles briefly but I'm still not exactly sure what they are. I tried replacing the line for wantedRotationAngle to -90 instead of target.eulerAngles.y and I got the right rotation, but it still wont follow my FPC.
Any ideas? Thanks.
Edit
Fixed now. Not quite sure what I was doing wrong but it had something to do with having the movement scripts attached to the Graphics part of the FirstPersonController and the SmoothFollow attached to the FPC or vice versa. Thanks anyways.