using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class camera : MonoBehaviour { public Rigidbody2D FollowedObject; public Vector2 offset; private Vector2 dest; private Vector2 Vel; private Rigidbody2D RB; public float Speed; private void Awake() { RB = this.gameObject.GetComponent(); } void Update() { dest = FollowedObject.position + offset; Vel = RB.velocity; RB.velocity = (new Vector2(MathF.Round(dest.x*4, MidpointRounding.AwayFromZero)/4, MathF.Round(dest.y*4, MidpointRounding.AwayFromZero)/4) - RB.position)*Vector2.Distance(RB.position, FollowedObject.position)/Speed; } }