Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PlayerController : MonoBehaviour
- {
- public static PlayerController instance;
- private Rigidbody rb;
- public float _speed = 1;
- private float _playerSpeed;
- // Start is called before the first frame update
- void Awake()
- {
- instance = this;
- rb = GetComponent<Rigidbody>();
- }
- private void Update()
- {
- }
- // Update is called once per frame
- void FixedUpdate()
- {
- _playerSpeed = Mathf.Lerp(_playerSpeed, _speed, Time.deltaTime);
- rb.velocity = new Vector3(rb.velocity.x, rb.velocity.y, (_playerSpeed * 100 * Time.fixedDeltaTime));
- if (transform.position.z - Camera.main.transform.position.z >= 15f) //Move camera to follow player
- {
- Camera.main.transform.position = new Vector3(0, Camera.main.transform.position.y, transform.position.z - 15f);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement