Forum rules - please read before posting.

Fixing sprite to a position

Hi is there a way to fix a sprite to a certain position at all times, like a moon or sky that stays central to camera at all times? Almost opposite of parallax?

Comments

  • As I understood, you want a sprite follow camera all the time.

    You can write a script that GameObject follows the camera and attach on it.


    [SerializeReference] Vector2 _offset; [SerializeField] float smoothTime = .3f; private Vector3 velocity = Vector3.zero; private void Update() { FollowCamera(gameObject); } private void FollowCamera(GameObject obj) { var mainCameraPos = Camera.main.transform.position; var followWithOffset = new Vector2 ( mainCameraPos.x + _offset.x, mainCameraPos.y + _offset.y ); //To avoid Object Shaking obj.transform.position = Vector3.SmoothDamp ( obj.transform.position, followWithOffset, ref velocity, smoothTime ); }
  • You might also be able to just parent the sprite to the MainCamera object.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.