Odd sprite issues with rotation and offset

nathanjwtxnathanjwtx Posts: 28Member

i've run into an odd issue with sprites and rotating them. The Kenney tank sprites all point downwards and so need rotating 90 to face Godot's 0 degrees. No big deal. However, this played havoc with my code that rotates the barrel. I then remembered in a @KidsCanCode tutorial he said he pre-rotated them. I switched to those assets and bingo, no wierd rotation issues. so 2 questsons:
1. why does the starting rotation impact code to rotate to a given position? It seemed to be 90 degrees off each time (visually speaking as the the calc is in radians)
2. in the unrotated assets I had to set the offset in X whereas in the rotated ones I had to set it in Y to get it in the same starting position. This one is really confusing.
I guess I could correct the rotation calc to allow for 90 but i don't understand why I would need to

Comments

  • CalinouCalinou Posts: 281Admin Godot Developer

    When you transform a parent node (translate/rotate/scale), all the children will be impacted by the same transformation.

    Due to this, depending on the kind of game you're developing, you may find it more logical to create tanks that point upwards in their default rotation.

  • nathanjwtxnathanjwtx Posts: 28Member

    So regardless of the rotational transform displayed, the origin doesn't change?

    Why would the need to do the offset in Y vs X change though?

  • MegalomaniakMegalomaniak Posts: 1,490Admin
    edited September 10

    Whats your node hierarchy like? You could always use a intermediary node2D as parent of the turret to do the correctional rotation there, then control the turrets rotation from code. The intermediary node would always inherit parents rotation and the turret in turn the intermediaries... if that makes sense.

    edit: also note that kenny.nl assets are built specifically for unity, so that might introduce the "issue". I don't really recall, but unity might have some of the axis flipped so that what is positive direction would perhaps be the negative along that axis in godot instead..

Sign In or Register to comment.