Hello,
I’m tyring to make a simple multiplayer spaceshooter. For the Spaceships I want a 3rd person camera just binhind and a little above the player ships.
The Camera is atached to the Player Ship Prefab as an Child object.
Now I want a bit of smoothness in the camera’s Motion Relative to its Parent object.
I only found some Scripts with Targets, but I have no Target, just looking forward.
Somebody knows a Solution for this?
Smoothing the Cameras Position without a Target (only its Parent) to follow?
DaDonik
2
I would not parent the camera to the spaceship.
The way i normally do this kind of stuff is as follows:
-
Use the forward vector of the spaceship, multiply it by minus the distance you want the camera to stay behind the ship.
-
Do the same with the up vector of the ship.
Now you have a position where you want the camera to move to. All thats left to do is to lerp the camera towards this position.
This will do the job, in fact id does even more than requested 
using UnityEngine;
using System.Collections;
public class CameraFollow : MonoBehaviour
{
public Camera TheCamera;
public Transform TargetToFollow;
public Vector3 DesiredOffset;
public float Speed;
void Update ()
{
// Calculate offset vector.
Vector3 v3TargetOffset = TargetToFollow.position;
v3TargetOffset += (DesiredOffset.z * TargetToFollow.transform.forward);
v3TargetOffset += (DesiredOffset.y * TargetToFollow.transform.up);
v3TargetOffset += (DesiredOffset.x * TargetToFollow.transform.right);
// Lerp the camera.
Vector3 v3CurrentCameraPos = TheCamera.transform.position;
v3CurrentCameraPos.x = Mathf.Lerp(v3CurrentCameraPos.x, v3TargetOffset.x, Speed * Time.deltaTime);
v3CurrentCameraPos.y = Mathf.Lerp(v3CurrentCameraPos.y, v3TargetOffset.y, Speed * Time.deltaTime);
v3CurrentCameraPos.z = Mathf.Lerp(v3CurrentCameraPos.z, v3TargetOffset.z, Speed * Time.deltaTime);
TheCamera.transform.position = v3CurrentCameraPos;
TheCamera.transform.LookAt(TargetToFollow.transform);
}
}