Forum rules - please read before posting.

Sprite not visible during gameplay when changing transform.position in custom script's Update

Hello,
I was trying to add a simple animation to a GameObject in scene with SpriteRenderer component by adding a simple custom MonoBehaviour script to the GameObject, where i set the transform.position in Update method to make the sprite move on a circle.
When running the game the sprite is not visible in scene, while in Editor all seems fine, and the sprite moves as expected.
Is it possible to add animations like this, or did i upset some deeper AC logic by messing with the sprite's transform.position in such a direct way? (there are not any objects behind or in front of the sprite which could potentially obscure it)
Thank you.

Comments

  • Welcome to the community, @Laredo.

    In what way is AC involved? Is the sprite that of a character, or some object that is normally being controlled by AC in some way?

    If you select the sprite's object in the Hierarchy, check its Inspector and position in the Scene window - is it in front of AC's MainCamera?

    If AC is not involved directly, then I wouldn't expect there to be a conflict - try running your script / effect in a fresh, non-AC scene.

  • Thank you!
    I'm so sorry for wasting your time. The sprite's position was ok, but I forgot to check the position of the reference object I used for setting the center of the circle path, it was incorrectly positioned on the Z axis relative to the camera. :( You mentioning the camera position lead me to discovering the problem. I should debug more thoroughly before posting next time.
    Thank you for your hard work on AC! I very much enjoy learning to work with it.

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.