- Home /
Question by
bugcode01 · Aug 14, 2020 at 03:59 PM ·
camerascripting problemplayercamera-movementtransform.position
Multiple Targets Camera
Hi there, I’m making a 2d game, is almost finished but the camera scripts is missing, I’d like to make a camera like super mario, I created a function to follow the player it work, but when the transformation changes the camera stops following him. helpe me please =) !
Comment
public class Cam : $$anonymous$$onoBehaviour { public Transform player;
// public Transform [] target; //you can make an array of transform???
/// 1 transformation
/// 2 transformation
/// 3 transformation
public float distanceToPlayer;
public float speedCam;
public float height;
private void Start()
{
player = GameObject.FindGameObjectWithTag("Player").transform;
}
void Follow()
{
Vector3 newPosition = player.position + new Vector3(0, height, -distanceToPlayer);
transform.position = Vector3.Lerp(transform.position, newPosition, speedCam * Time.deltaTime);
//
}
private void Update()
{
Follow();
}
}
Your answer
Follow this Question
Related Questions
How can I get a Capsule to move and rotate in the direction the cam is facing? 1 Answer
Camera follow player with code 3 Answers
How do I get camera movement through controller input. 1 Answer
Cannot Rotate Player after Matching Camera Rotation? 0 Answers
Why is the camera movement framerate dependent after adding deltaTime? 0 Answers